Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3483976
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:44:10+00:00 2026-05-18T10:44:10+00:00

There is something fishy about the calculation of far future dates when done on

  • 0

There is something fishy about the calculation of far future dates when done on the browser side (Safari 5.0.1), passing strings into the Date() constructor:

I narrowed it down to the February-March transition in year 22034:

d = new Date('1 Mar 22034')
Tue Feb 28 22034 00:00:00 GMT+0000 (GMT)

Feeding it any later date, the constructor always returns a Date object off-by-one day!

What about earlier dates? The last day in February looks good:

d=new Date('28 Feb 22034')
Tue Feb 28 22034 00:00:00 GMT+0000 (GMT)

My gut-feeling tells me that looks like a leap-year related bug. But what is the pattern in play here, what could be the explanation of the bug?


Edit:

How about if we ask for February 29th?

d=new Date('29 Feb 22034')
Wed Mar 01 22034 00:00:00 GMT+0000 (GMT)

That returns the last of Feb + 1 day (its standard behavior).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:44:10+00:00Added an answer on May 18, 2026 at 10:44 am

    It’s because the date format you’re giving new Date() is non-standard. The fact you’re getting anything is because Safari is doing you a favor. (See section 15.9.1.15 of the spec for valid formats; basically a simplified ISO-8601. And having any standard for parsing date/time strings is relatively new [5th edition].)

    If you use a standard constructor, e.g., new Date (22034, 2, 1) (months start at zero, so that’s March 1, 22034), it works fine. You can test it like this (live copy):

    display("With non-standard string: " + new Date("1 Mar 22034"));
    display("Using standard constructor: " + new Date(22034, 2, 1));
    

    Which for me using Safari for Windows results in:

    With non-standard string: Tue Feb 28 22034 00:00:00 GMT+0000 (GMT Standard Time)

    Using standard constructor: Wed Mar 01 22034 00:00:00 GMT+0000 (GMT Standard Time)

    As you can see, the first line shows the incorrect date, while the second line shows the correct one.

    The standard constructor also works correctly in Chrome, Opera, and Firefox (all under Ubuntu), IE6, IE7, and IE8: http://jsbin.com/ogiqu

    If it were really true that Safari couldn’t handle that date (as opposed to not parsing the non-standard string you gave it reliably), it would be a surprising Safari-specific bug. From section 15.9.1.1 of the spec:

    Time is measured in ECMAScript in milliseconds since 01 January, 1970 UTC. In time values leap seconds
    are ignored. It is assumed that there are exactly 86,400,000 milliseconds per day. ECMAScript Number values
    can represent all integers from –9,007,199,254,740,991 to 9,007,199,254,740,991; this range suffices to
    measure times to millisecond precision for any instant that is within approximately 285,616 years, either
    forward or backward, from 01 January, 1970 UTC.

    But as Safari seems to handle it fine when you don’t ask it to go off-piste, apparently the problem is in the parsing code for non-standard strings.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there something similar to save for the update task? If I want to
Is there something like anonymous inner classes (used in Java) in C#? I explain
is there something similar to the NotImplementedException on the android platform? thanks!
Is there something similar with spring jdbctemplate for c# ? I am not seeking
Is there something that is similar to XmlTextReader in terms of performance, but using
Is there something that provides auto-completion for PostgreSQL? I'm looking for something similar to
Is there something I can put in the code for an HTML page I
I am going through the Zend Framework "quickstart" tutorial at the mo'. I have
I am using spring frameworking following is the mapping of url to controller <bean
I'm attempting to implement the atomic library from the C++0x draft. Specifically, I'm implementing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.