You can use Date.getTime() to get the representation of the Date object in milliseconds, so the (fairly accurate) approximation will be:
timeoutHandle = setTimeout(function() {
The return value of setTimeout and setInterval is just a kind of "timer identifier" - you use it to stop the timer with clearTimeout and clearInterval , it does not change dynamically.
Edit: As @Rocket points out, yes, you can use Date.now() instead of new Date().getTime() .
source share