I'm using Python 3.7. I have this defined in my settings file ...
TIME_ZONE = 'America/New York'
I want to make the "now()" function timezone aware, so I can do some date subtraction ...
int(round((datetime.now(settings.TIME_ZONE) - article.created_on).total_seconds() / 60)) > 10
But I keep getting this error
TypeError: tzinfo argument must be None or of a tzinfo subclass, not type 'str'
How do I convert my constant into a timezone?
Use the pytz
library.
tz = pytz.timezone(TIME_ZONE)
This will give you a tzinfo object that you can pass to .now()