简体   繁体   中英

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

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 ulan@chromium.org ,

This issue is fixed in version 3.29.39

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM