Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

JavaScript Date functions in Safari

My JavaScript program runs fine in several browsers but not Safari. The following JavaScript code snippet demonstrates the problem:

var seconds=2264773322794;
day = new Date();
day.setTime(seconds);
alert(day);

Most browsers show this as October 7, 2041, but Safari shows this as January 18, 2038, which is obviously wrong. I'm really stuck doing anything with Safari if it can't handle this.

Posted on Oct 14, 2005 1:44 PM

Reply
2 replies

Dec 19, 2005 8:12 AM in response to Amit Chaturvedi

Yes, the "Year 2038 Bug" is nicely documented at http://www.2038bug.com/ . It's odd, though, that most implementations of JavaScript on most platforms are not affected by the 2038 bug; Safari on the Mac is the only browser/platform combination that I have found that displays the problem. It is also noteworth that the bug affects the 32-bit UTC scheme, which measures time in seconds. However, by convention, JavaScript measures time in milliseconds. Apparently, Safari stores time values in UTC seconds with a separate field for one-thousandths of a second. Other browsers must use some other scheme, as they are able to project far beyond the year 2038 without running into a brick wall.

JavaScript Date functions in Safari

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.