Jquery Javascript时间加秒?

Jquery Javascript时间加秒?,jquery,Jquery,假设当前时间是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秒。如果我答对了问题,我会使用以下方法: var t = Math.Round(new Date.

假设当前时间是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秒。

如果我答对了问题,我会使用以下方法:

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

您希望第一行执行一天需要6秒以上吗;如果当前时间=或高于时间?高于什么时间?高于可变时间。可变时间=当前时间+6秒你需要改写这个问题,它没有意义。