-2

假设当前时间是 24:56:04

我想做这样的事情:

variable time = current time (24:56:04) + 6 seconds.

If current time = or higher than time: print 'Success'

else print 'Fail'.

有可能这样做吗?如何?

另一个答案没有回答我的问题。因为我需要知道当前时间是否 = 上一次 + 10 秒。

4

1 回答 1

0

如果我的问题是正确的,我会使用类似的东西:

var t = Math.Round(new Date.getTime()/1000) + 6;
//operations or what here
if(Math.Round(new Date().getTime()/1000) >= t)
//Print success
else
//Print false

当然你可以跳过舍入和除法部分,让你的测量更快更准确(1ms精度)

于 2013-05-07T22:24:40.367 回答