In [removed] Why new Date('2012-1-15') - new Date('2012-01-15') == 21600000

后端 未结 3 1802
生来不讨喜
生来不讨喜 2020-12-29 20:04

I\'m confused but in javascript:

> new Date(\'2012-1-15\') - new Date(\'2012-01-15\')
  21600000

Why is that? (21600000 / 1000 / 3600 ==

3条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-12-29 20:57

    a= new Date('2012-1-16') 
    b= new Date('2012-01-16')
    alert(a);
    alert(b);
    

    For the first case, the constructor function sets time to 00:00 in your time zone. But in the second case, it initialize time relative to GMT +00.00

提交回复
热议问题