到目前为止,代码运行良好。我只是把它作为参考。
import datetime
#prints current local datetime with a time zone of none
dt_today = datetime.datetime.today()
# gives option to introduce a timezone
dt_now = datetime.datetime.now()
# utcnow does not signify a timezone-aware datetime
# instead it offers utc info set to now but tcinfo still set to none
dt_utcnow = datetime.datetime.utcnow()
print(dt_today)
print(dt_now)
print(dt_utcnow)
print(dt_utcnow.strftime('%Y-%m-%d %H:%M:%S.%f %Z'))
我尝试了显而易见的:
dt_gmt = datetime.datetime.gmt()
但那没用。