Getting a timezone-aware date in utc
timezone is enough for date subtraction to work.
But if you want a timezone-aware date in your current time zone, tzlocal
is the way to go:
from tzlocal import get_localzone # pip install tzlocal
from datetime import datetime
datetime.now(get_localzone())
PS dateutil
has a similar function (dateutil.tz.tzlocal
). But inspite of sharing the name it has a completely different code base, which as noted by J.F. Sebastian can give wrong results.