Javascript时间戳记(如果经过10分钟)。

Bri*_*ian 1 javascript time date

我试图弄清楚如果过了10分钟,那么就会发生一个动作。现在我所拥有的只是这个,我不太了解时间戳记。例如1370246236916 ...时,时,日,年,分钟或秒等在哪里。

var ten_mins = new Date().getTime();
var time = data_base_time;
var time_to_ago = time - new Date().getTime()+100000;

if( time >= time_to_ago){
   //Ten minutes went by
}
Run Code Online (Sandbox Code Playgroud)

Ben*_*enM 5

为什么不使用setTimeout()

window.setTimeout(function() {  
    // 10 minutes have gone by. Execute a function here.
}, 600000);
Run Code Online (Sandbox Code Playgroud)