0

time_string="1569834192" #in epoch format. I want to convert it in "US/Eastern" timezone. But The output I get is as follows: 2019-09-30 14:33:12-04:56 I want exact time instead of this -04:56

my code: time_string="1569834192" print datetime.fromtimestamp(time_string, tz= pytz.timezone('US/Eastern')).strftime("%Y-%m-%d %H:%M:%S")

output: 2019-09-30 14:33:12-04:56

time_string="1569834192" print datetime.fromtimestamp(time_string, tz= pytz.timezone('US/Eastern')).strftime("%Y-%m-%d %H:%M:%S")

2019-09-30 14:33:12-04:56

1 Answers1

1

Python 3 code:

import pytz

from datetime import datetime

time_string = 1569834192
us_western = pytz.timezone('US/Eastern')
print(datetime.fromtimestamp(time_string, us_western))
print(datetime.fromtimestamp(time_string, us_western).strftime("%Y-%m-%d %H:%M:%S"))

Outputs:

2019-09-30 05:03:12-04:00
2019-09-30 05:03:12