How to get current UK time in Google App Engine

前端 未结 3 1916
你的背包
你的背包 2020-12-19 11:53

Under python on my machine I can run datetime.now() to get the local time. If I inspect time.daylight flag it is set to 1 because we a

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-19 12:35

    I've been able to get this working:

    import pytz
    import datetime
    
    tz = pytz.timezone('Europe/London')
    
    print datetime.datetime.now(tz)
    

    It appears Google App Engine already imports a few modules by default, including pytz and datetime, so perhaps there is no need to explicitly import them.

提交回复
热议问题