Andrey Zhminka
Andrey Zhminka

Reputation: 253

Incorrect creating date object in javascript via "new Date()" in Chrome

The problem manifests irregularly and only occurs in Chrome. During the creation of the date object in JavaScript via new Date("..some date time string.."), it occasionally returns the date incorrectly as 6 Sep 2013 12:28:48 GMT+0300 (FLE Daylight Time). I investigated all of the source code and did not find this date anywhere. I attempted to create the date object via all accessible constructors, but was getting the same incorrect result occasionally. Then, I created the date object via Date.parse(), which appears to always work correctly.

enter image description here enter image description here

It happened very rarely. Browser cache had cleared in time on. This can occur for any date and time string. userAgent string: "Mozilla/5.0(WindowsNT6.2;WOW64)AppleWebKit/537.36(KHTML,likeGecko)Chrome/29.0.1547.76Safari/537.36"

Upvotes: 3

Views: 2055

Answers (1)

linstantnoodles
linstantnoodles

Reputation: 4400

That's unusual. The date parsing functions are implementation dependent, so they may interpret date strings differently. But the issue you're having seems to suggest that Date.parse() uses a different implementation than the function that gets called by the new Date() constructor, when in fact they should be the same.

See the following posts:

Upvotes: 1

Related Questions