datetime.datetime.utcnow()
datetime.datetime(2010, 2, 25, 4, 14, 37, 366086)
Why does this datetime not have any tz info say its a utc date.
datetime.datetime.utcnow()
datetime.datetime(2010, 2, 25, 4, 14, 37, 366086)
Why does this datetime not have any tz info say its a utc date.
UTC dates don't need any timezone info since they're UTC, which by definition means that they have no offset.
The standard Python libraries don't include any tzinfo classes. I can only guess at the reasons. Personally I think it was a mistake not to include a tzinfo class for UTC, because that one is uncontroversial enough to have a standard implementation.
That means it is timezone naive, so you can't use it with datetime.astimezone
you can give it a timezone like this
import pytz # 3rd party
u=datetime.utcnow()
u=u.replace(tzinfo=pytz.utc)
now you can change timezones
print datetime.astimezone(u, pytz.timezone("EST"))