0
import datetime
import pytz
time_zone=pytz.timezone('America/Chicago')
a=datetime.datetime(2019,1,1,0,0,0,tzinfo=time_zone)
b=datetime.datetime.fromtimestamp(a.timestamp(),time_zone)
print("The value of a is ",a)
print("The value of b is ",b)

I am trying to convert a local time user input in the form of mm/dd/yyyy into unix and then back, but I can't seem to get these two to agree after converting to unix.

screen

Vitalizzare
  • 4,496
  • 7
  • 13
  • 32
  • Does this answer your question? [Weird timezone issue with pytz](https://stackoverflow.com/questions/11473721/weird-timezone-issue-with-pytz) – FObersteiner Oct 11 '22 at 04:46
  • In short: you must **localize** to build a datetime object with a pytz timezone. Or use a library that's not deprecated, see answers to linked dupe. – FObersteiner Oct 11 '22 at 04:48

0 Answers0