Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

settimeout javascript see how much time is left

var timeout = setTimeout(function() {}, 3600 * 1000);

setInterval(function() {
    console.log('Time left: '+getTimeLeft(timeout)+'s');
}, 2000);

function getTimeLeft(timeout) {
    return Math.ceil((timeout._idleStart + timeout._idleTimeout - Date.now()) / 1000);
}
Source by newbedev.com #
 
PREVIOUS NEXT
Tagged: #settimeout #javascript #time #left
ADD COMMENT
Topic
Name
4+7 =