parsing - javascript parse datetime string in NewYork Timezone -


i have datetime string represents local new york time.

12/30/2020 12:00 pm 

i want parse in javascript epoch. parsing has work users may in different timezones.

what did

moment("07/13/2015 01:45 -04:00", 'm/d/yyyy h:mm z').unix() 

but not because had hardcode

-04:00 

and assume date i'm parsing eastern daylight saving time.

use moment-timezone add-on.

moment.tz("12/30/2020 12:00 pm", "m/d/yyyy h:mm a", "america/new_york").unix() 

also, aware there's no guarantee rules particular time zone persist future. knows if 2020 if government won't change dst rules again last did in 2007. sure, it's not affect date in december, in general case can't certain. when consider other time zones have changes - dozen or more changes globally every year.

oh, , 1 minor petpeeve... said:

... epoch.

the word epoch means "the start of something". unix epoch 1970-01-01t00:00:00z. it's never else. value unix timestamp based on epoch - not epoch. "epoch time" misnomer. (there other epochs used in computing, not relation unix time).


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -