Sometimes, we want to get a value of datetime.today() in Python that is time zone aware.
In this article, we’ll look at how to get a value of datetime.today() in Python that is time zone aware.
How to get a value of datetime.today() in Python that is time zone aware?
To get a value of datetime.today() in Python that is time zone aware, we can use the pytz module.
For instance, we write
import pytz
from datetime import datetime
utc_now = datetime.now(pytz.utc)
to call datetime.now with pytz.utc to get the current datetime in UTC.
Conclusion
To get a value of datetime.today() in Python that is time zone aware, we can use the pytz module.