I went into the environment variables for my lambdas and changed TZ
to EST
. My question is, is that valid? I keep seeing people do stuff like America/Florida
for example. What if I just want a blanket timezone instead of specify a location?
CodePudding user response:
Lambda env var docs: TZ – The environment's time zone (UTC). The execution environment uses NTP to synchronize the system clock... The keys for these environment variables are reserved and cannot be set in your function configuration.
So the environment uses UTC. Use your runtime language to handle time zone conversions.
For example, Python:
from zoneinfo import ZoneInfo
from datetime import datetime
dt_ny = datetime.now(tz=ZoneInfo('America/New_York'))
dt_est = dt_ny.astimezone(ZoneInfo('EST'))
print(dt_ny) # 2021-12-08 15:01:38.958676-05:00
print(dt_est) # 2021-12-08 15:01:38.958676-05:00
print(dt_ny == dt_est) # True during the winter, False in summer
The IANA timezone database's America/Florida
-style formats are widely supported in programming languages. Unlike the Z 2:00
format or EST
, they don't get messed up by Summer Time ("Daylight Saving Time"). Even though EST
is the same as America/New_York
today, it won't during the summer, when New York switches to EDT
. Time zones seem dead simple until you start working with them.