JavaScript, time zones, and daylight savings time

后端 未结 2 633
一个人的身影
一个人的身影 2020-12-19 09:10

Welcome to this week\'s episode of Yet Another Time Zone Question:

I\'ve done a fair bit of reading on SO, tried to manipulate moment.js and date.js

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-19 09:48

    Ah, I think I finally see what you're saying. You want to say something like, "The current time in NYC is _" based on the time that's on the user's computer, and while there's support (at least in the docs) for setTimezone("EDT") there doesn't appear to be support for setTimezone("America/New York"). You'll either have to hard code the dates for when to switch between EDT and EST (based on current time GMT, which you can get from the user's computer), or use a 3rd party API (or do this on the server side).

提交回复
热议问题