the Gravity of Python 2
Kushal Kumaran
kushal.kumaran at gmail.com
Thu Jan 9 04:21:51 EST 2014
Ben Finney <ben+python at benfinney.id.au> writes:
> Kushal Kumaran <kushal.kumaran at gmail.com> writes:
>
>> Roy Smith <roy at 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 489 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20140109/feb4d171/attachment.sig>
More information about the Python-list
mailing list