Contents

AWS Lambda Local Time Fix

Contents
Note
I use this code snippet when I need to see the actual local time.
For example when you need to use a “CreationTime” tag on some resources.
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)