0

I am building a scheduling application, in Django, and I am working with the pytz package in python to aware DateTime objects.

If, for instance, I create a datetime object:

original = datetime.datetime(1900,6,6,10,40, tzinfo=pytz.timezone('US/Eastern'))
print(original)

I get:

1900-06-06 10:40:00-04:56

The UTCOffset is -04:56. Is it possible to work with just hours so -5:00?

abhivemp
  • 932
  • 6
  • 24
  • I've added a related question as to why I am getting `-04:56`: https://stackoverflow.com/questions/74354161/why-is-pytz-us-eastern-0456-and-not-0500 – abhivemp Nov 07 '22 at 23:33
  • 1
    duplicate of [Python pytz timezone function returns a timezone that is off by 9 minutes](https://stackoverflow.com/q/35462876/10197418) and [Weird timezone issue with pytz](https://stackoverflow.com/q/11473721/10197418). **tl;dr**: use `localize`, don't set pytz timezone directly. **better**: use [zoneinfo](https://docs.python.org/3/library/zoneinfo.html) instead of pytz. it's deprecated. – FObersteiner Nov 09 '22 at 14:08

0 Answers0