Skip to content

Instantly share code, notes, and snippets.

@ffturan
Last active July 21, 2023 07:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffturan/234730392091c66134aff662c87c152e to your computer and use it in GitHub Desktop.
Save ffturan/234730392091c66134aff662c87c152e to your computer and use it in GitHub Desktop.
Fix AWS lambda function timezone [python]
import json
import os
import time
#
vLocalTimeZone='US/Eastern'
#
def lambda_handler(event, context):
# Run time in UTC
vNowUTC=time.strftime('%X %x %z')
print(vNowUTC)
os.environ['TZ'] = vLocalTimeZone
time.tzset()
# Run time in local tz
vNowLocal=time.strftime('%X %x %z')
print(vNowLocal)
@MLpranav
Copy link

MLpranav commented May 1, 2021

You're a lifesaver man, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment