startOf 和 endOf MomentJS 方法之间的时区不正确
Timezone incorrect between startOf and endOf MomentJS methods
使用 momentjs
时出现非常奇怪的问题:
moment().startOf('month').toDate()
产生:
Sun Nov 01 2020 00:00:00 GMT-0400 (Eastern Daylight Time)
moment().endOf('month').toDate()
产生:
Mon Nov 30 2020 23:59:59 GMT-0500 (Eastern Standard Time)
为什么时区发生了变化?为什么开始选择EDT
而结束选择EST
?
startOf('month')
和 endOf('month')
returns 浏览器时区中月份的第一个和最后一个日期。
2020 年 11 月 1 日,daylight savings time ended in the USA,所以直到 11 月 1 日,您浏览器的时区将是美国东部时间(如果您在东部时区),11 月 1 日之后将是美国东部时间.
如果你想得到一个特定的基于时区的时间,你可以使用moment-timezone。
使用 momentjs
时出现非常奇怪的问题:
moment().startOf('month').toDate()
产生:
Sun Nov 01 2020 00:00:00 GMT-0400 (Eastern Daylight Time)
moment().endOf('month').toDate()
产生:
Mon Nov 30 2020 23:59:59 GMT-0500 (Eastern Standard Time)
为什么时区发生了变化?为什么开始选择EDT
而结束选择EST
?
startOf('month')
和 endOf('month')
returns 浏览器时区中月份的第一个和最后一个日期。
2020 年 11 月 1 日,daylight savings time ended in the USA,所以直到 11 月 1 日,您浏览器的时区将是美国东部时间(如果您在东部时区),11 月 1 日之后将是美国东部时间.
如果你想得到一个特定的基于时区的时间,你可以使用moment-timezone。