Skip to content Skip to sidebar Skip to footer

How To Get Current Time In Pacific Timezone When Import Pytz Fails?

I'm working in an environment (AWS Lambda) where import pytz doesn't work. The environment is set to UTC. How can I get the current time in the U.S. Pacific Timezone in this enviro

Solution 1:

If you don't have access to pytz in your environment, maybe you have access to python-dateutil. In that case you can do:

import datetime
import dateutil.tz

eastern = dateutil.tz.gettz('US/Eastern')
datetime.datetime.now(tz=eastern)

Post a Comment for "How To Get Current Time In Pacific Timezone When Import Pytz Fails?"