datetime.utcnow()
This call is returning an incorrect datetime, delayed from UTC/GMT by 1 hour (check in: http://www.worldtimeserver.com/current_time_in_UTC.asp).
Is it working like it should be?
For example, it's returning, right now:
2015-02-17 23:58:44.761000.
Current UTC time is: 00:58, not 23:58
Returns the current UTC date and time.
datetime. utcnow() Returns the current utc time but is not timezone aware.
You should always try to work with DateTime objects that have Kind=Utc , except during i/o (displaying and parsing). This means you should almost always be using DateTime. UtcNow , except for the cases where you're creating the object just to display it, and discard it right away.
I know I'm five years late, but I had the same problem tonight. In my experience, the solution to the problem was to use the aware UTC datetime:
utc_dt_aware = datetime.datetime.now(datetime.timezone.utc)
If you google "utcnow() wrong" this is the first result you get, so I thought it would be good to answer anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With