This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                7年前关闭。
            
        

下列:

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());​


结果是 :


  2012年2月1日,星期三00:00:00 GMT-0200(Horáriobrasileiro deverão)
  0
  2012年2月1日,星期三,00:03:00 GMT-0200(Horáriobrasileiro deverão)
  0


我的3秒在哪里?

最佳答案

您要添加3分钟,而不是3秒。

更改

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




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

关于javascript - JavaScript日期getSeconds返回0 ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/12738715/

10-12 18:10
查看更多