Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strange Date behavior in Chrome

Why these nearly similar date objects give different results in Chrome 37?

var d2014 = new Date(2014, 0, 1);
alert(d2014.getFullYear()); // 2013

var d2015 = new Date(2015, 0, 1);
alert(d2015.getFullYear()); // 2015

In IE11 I get "2014" and "2015" as expected. Browser works in Russian locale. Conversion to strings gives the following results:

d2014.toString();    // Tue Dec 31 2013 23:00:00 GMT+0300 (RTZ 2 (зима))
d2015.toString();    // Thu Jan 01 2015 00:00:00 GMT+0300 (RTZ 2 (зима))

d2014.toUTCString(); // Tue, 31 Dec 2013 20:00:00 GMT
d2015.toUTCString(); // Wed, 31 Dec 2014 21:00:00 GMT
like image 589
Boris Mitchenko Avatar asked Oct 03 '14 22:10

Boris Mitchenko


1 Answers

This is a chrome specific issue, you can view the discussion here https://code.google.com/p/v8/issues/detail?id=3116 and in https://code.google.com/p/chromium/issues/detail?id=417640 look for #31 [email protected],

This issue is fixed in version 3.29.39

like image 104
Naeem Shaikh Avatar answered Nov 19 '22 10:11

Naeem Shaikh