Clock in different time zones

前端 未结 6 1483
南方客
南方客 2021-01-12 18:08

I am trying to create two clocks on a website that says two times on it. One from London and the other from New York.

I have been able to create a clock that reads t

6条回答
  •  一个人的身影
    2021-01-12 18:37

    To do this properly, you will need a time zone database, such as one of the ones I listed here.

    All of the other answers to this question are making the mistake in thinking that a "time zone" and a "time zone offset" are the same thing. They are not. For example, the time zone for London is Europe/London, which can have either a +0 or +1 offset depending on what time of year it is. The time zone for New York is America/New_York, which can have either a -5 or -4 offset based on a completely different set of dates than London.

    You might want to look at moment-timezone:

    moment().tz("America/New_York").format()
    

提交回复
热议问题