代码之家  ›  专栏  ›  技术社区  ›  Konstantin Dinev

1925年之前的JavaScript日期中出现错误的分和秒[重复]

  •  10
  • Konstantin Dinev  · 技术社区  · 6 年前

    DateTimeOffset ,默认设置为 "0001-01-01T00:00:00+00:00" .

    console.log(new Date("2001-01-01T00:00:00+00:00").toString())
    // Mon Jan 01 2001 02:00:00 GMT+0200 (Eastern European Standard Time)
    console.log(new Date("1001-01-01T00:00:00+00:00").toString())
    //Thu Jan 01 1001 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1801-01-01T00:00:00+00:00").toString())
    //Thu Jan 01 1801 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1901-01-01T00:00:00+00:00").toString())
    //Tue Jan 01 1901 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1961-01-01T00:00:00+00:00").toString())
    //Sun Jan 01 1961 03:00:00 GMT+0300 (Eastern European Standard Time)
    console.log(new Date("1921-01-01T00:00:00+00:00").toString())
    //Sat Jan 01 1921 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1931-01-01T00:00:00+00:00").toString())
    //Thu Jan 01 1931 03:00:00 GMT+0300 (Eastern European Standard Time)
    console.log(new Date("1922-01-01T00:00:00+00:00").toString())
    //Sun Jan 01 1922 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1923-01-01T00:00:00+00:00").toString())
    //Mon Jan 01 1923 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1924-01-01T00:00:00+00:00").toString())
    //Tue Jan 01 1924 02:02:04 GMT+0202 (Eastern European Standard Time)
    console.log(new Date("1925-01-01T00:00:00+00:00").toString())
    //Thu Jan 01 1925 02:00:00 GMT+0200 (Eastern European Standard Time)

    如你所见,我对日期进行了研究,想知道这发生在哪个日期之前,但问题可能不是1925年,而是当前日期之前的某个时间。有人知道为什么会这样吗?

    按要求截图 enter image description here

    1 回复  |  直到 6 年前
        1
  •  7
  •   Nadya    6 年前

    new Date("1883-01-01T00:00:00+00:00")
    Sun Dec 31 1882 16:07:02 GMT-0752 (Pacific Standard Time)
    new Date("1884-01-01T00:00:00+00:00")
    Mon Dec 31 1883 16:00:00 GMT-0800 (Pacific Standard Time)
    

    事实上,你可以追溯到1883年11月18日。

    new Date("1883-11-18T00:00:00+00:00")
    Sat Nov 17 1883 16:07:02 GMT-0752 (Pacific Standard Time)
    new Date("1883-11-19T00:00:00+00:00")
    Sun Nov 18 1883 16:00:00 GMT-0800 (Pacific Standard Time)
    

    Chrome非常努力地匹配时间,甚至计算出2010年埃及斋月暂停的夏令时。

    阅读更多信息: https://www.huffingtonpost.com/quora/how-when-and-why-were-tim_b_5838042.html