if I write
from datetime import timezone
I get the error ImportError: cannot import name timezone
Of course calling datetime.timezone
does not work either.
How do I debug this? I have wasted an hour and it is already late here.
datetime.timezone
was added in Python 3.2. So it is normal to get an import error in e.g. Python 2.7.
In Python 2.7, you can use the pytz
library.
import datetime
import pytz
myDate = datetime.datetime.now(pytz.utc)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With