How to get current time in Pacific Timezone when import pytz fails?

后端 未结 1 739
长情又很酷
长情又很酷 2021-01-21 11:17

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.

相关标签:
1条回答
  • 2021-01-21 12:13

    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)
    
    0 讨论(0)
提交回复
热议问题