2012-10-05 68 views
0

以下幾點:javascript日期getSeconds返回0

var a = new Date(2012,1,1); 
alert(a); 
alert(a.getSeconds()); 
a = new Date(a.getTime() + (180 * 1000)); // adds 3 seconds. 
alert(a); 
alert(a.getSeconds());​ 

resultsin:

週三2012年2月1日00::00 GMT-0200(巴西夏令時)
週三2012年2月1日00::00 GMT-0200(巴西夏令時)

在哪裏我的3個秒了嗎?

回答

3

要添加3分鐘,沒有3秒。

變化

a = new Date(a.getTime() + (180 * 1000)); // adds 3 seconds. 

a = new Date(a.getTime() + (3 * 1000)); // adds 3 seconds. 
+0

喔,我的上帝......我需要更多的睡眠。 謝謝! –