I am trying to get the corresponding Epoch Unix timestamp (in seconds) for the following New York date and time:
2020-09-25 09:30 New York Time.
Which according to https://www.epochconverter.com/timezones?q=1601040600&tz=America%2FNew_York correponds to:
Conversion results (1601040600)
1601040600 converts to Friday September 25, 2020 09:30:00 (am) in time zone America/New York (EDT)
This is what I have tried:
import datetime
import pytz
et = pytz.timezone('America/New_York')
mydt = datetime.datetime(2020,9,25,9,30,0,0,et)
myepoch = int(mydt.timestamp())
print('2020-09-25 09:30 ET Epoch: ', myepoch)
>>> OUTPUT
2020-09-25 09:30 ET Epoch: 1601043960
So it gives 1601043960
instead of 1601040600
. Why and what shall be done to get the right value?
Note the solution shall work for any date, so it must automatically take care of EST/EDT daylight saving.