Ben Finney <ben+pyt...@benfinney.id.au> writes: > Kushal Kumaran <kushal.kuma...@gmail.com> writes: > >> Roy Smith <r...@panix.com> writes: >> > How, in Python, do you get an aware UTC datetime object? >> >> My local copy of the python 3.2.3 docs says: >> >> classmethod datetime.utcnow() >> >> Return the current UTC date and time, with tzinfo None. This is >> like now(), but returns the current UTC date and time, as a naive >> datetime object. An aware current UTC datetime can be obtained by >> calling datetime.now(timezone.utc). See also now(). >> >> Hope this helps. > > No, that won't do what was asked. The ‘datetime.datetime.utcnow’ > function explicitly returns a naive datetime object, not an aware > datetime object. >
Yes, but the documentation for utcnow explicitly tells you how to get an aware object. "An aware current UTC datetime can be obtained by calling datetime.now(timezone.utc)." -- regards, kushal
pgpkuzTEDWuQ3.pgp
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list