Date.getHours Date.toLocalString returns different time

时间:2017-06-12 17:02:14

标签: javascript date

I have the code:

var d1 = new Date('1970-01-01');
d1.toLocaleString();             // (1) returns 1/1/1970, 3:00:00 AM
d1.getHours();                   // (2) returns 2

var d2 = new Date('2017-01-01');
d2.toLocaleString();             // (3) returns 1/1/2017, 2:00:00 AM 
d2.getHours();                   // (4) returns 2 

Why the (1) and (3) returns different time, but (2) and (4) the same?

Thanks in advance.

0 个答案:

没有答案