Setting timezone in Python

后端 未结 5 1835
我在风中等你
我在风中等你 2020-11-27 13:47

Is it possible with Python to set the timezone just like this in PHP:

date_default_timezone_set(\"Europe/London\");
$Year = date(\'y\');
$Month = date(\'m\')         


        
5条回答
  •  悲哀的现实
    2020-11-27 14:17

    You can use pytz as well..

    import datetime
    import pytz
    def utcnow():
        return datetime.datetime.now(tz=pytz.utc)
    utcnow()
       datetime.datetime(2020, 8, 15, 14, 45, 19, 182703, tzinfo=)
    utcnow().isoformat()
    
    '
    

    2020-08-15T14:45:21.982600+00:00'

提交回复
热议问题