datetime.datetime.utcnow()
Why does this datetime
not have any timezone info given that it is explicitly a UTC datetime
?<
To add timezone
information in Python 3.2+
import datetime
>>> d = datetime.datetime.now(tz=datetime.timezone.utc)
>>> print(d.tzinfo)
'UTC+00:00'
from datetime import datetime
from dateutil.relativedelta import relativedelta
d = datetime.now()
date = datetime.isoformat(d).split('.')[0]
d_month = datetime.today() + relativedelta(months=1)
next_month = datetime.isoformat(d_month).split('.')[0]
UTC dates don't need any timezone info since they're UTC, which by definition means that they have no offset.