我只想确认一下,我在stackoverflow上看到,我可以做到以下几点:
var current_time = +new Date();
console.log (current_time);
var fetch_time = +new Date();
console.log((fetch_time-current_time));
我现在只想知道这个差异是什么。毫秒?
Log Output
1375976707028
76
我只是想以最快的方式检查是否已经过了60秒。我宁愿避免任何类型的操作,如乘法或除法。
由于
答案 0 :(得分:2)
+
看起来有点奇怪,我只使用.getTime()
。
.getTime()
返回毫秒,因此与60000
进行比较。
答案 1 :(得分:2)
试一试:
var current_time = +new Date();
var fetch_time;
console.log (current_time);
setTimeout(function() {
fetch_time = +new Date();
console.log((fetch_time-current_time)); // 1000 -> ms, 1 -> s
}, 1000);