Javascript dates: what is the best way to deal with Daylight Savings Time?

后端 未结 3 1213
[愿得一人]
[愿得一人] 2020-12-09 10:40

In a previous question I wrote about a javascript date function that was mysteriously stopping on 11/07/101. Thanks to the stackoverflow users I was told my problem is Dayl

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-09 11:20

    Use Date.setHours(hour,min,sec,millisec) to set the hour default to noon: Date.setHours(11); (view reference)

    24 hours after noon on a day is guaranteed to be the next day, though on daylight savings time days it will be one hour off (which doesn't change the result in your script at all).

提交回复
热议问题