Friday, 22 June 2018

weird seconds offset in js date object in chrome

When looking at the valueOf value of a date object at the beggining of a year i expected to always receive zero seconds. The following code shows that until 1917 there was an offset of 54 seconds or 40 seconds in chrome. in IE i receive 0 seconds for all years.

Is there a reason for this? it seems to only happen in the last chrome version

   for(var i=0; i<2020;i++)
       if(!new Date(i,0,1).valueOf().toString().match("00000$"))
             console.log({
                    y:i,
                    s: new Date(i,0,1).valueOf().toString().match(/(\d{2})\d{3}$/)[1]})



from weird seconds offset in js date object in chrome

No comments:

Post a Comment