-2

Let's say current time is 24:56:04

And I want to do something like this:

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

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

else print 'Fail'.

Is it possible to do it this way? how?

The other answer does not answer my question. Because I need to know if curret time = previous time + 10 seconds.

Jony Kale
  • 111
  • 1
  • 1
  • 5

1 Answers1

0

If I got the question right I would use something like:

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

Of course you can skip rounding and dividing part, leaving you with faster and more accurate measurement (1ms accuracy)

Turnip
  • 35,836
  • 15
  • 89
  • 111