// first you can save a timeStamp when you create the timeout
let timerTime = 3600 * 1000 // you can save the timer time on a variable
const timer = setTimeout(() => {
// do something in future please
}, timerTime)
const timeStamp = Date.now() // with Date.now method you can get the timestamp
// after that you can do somenthing like this
const getTimeLeft = (timerTime, timeStamp) => {
const timeLeft = Math.ceil( (timerTime - (Date.now() - timeStamp)) / 60000)
return timeLeft
}
//Math.ceil round float
//with Date.now - timeStamp you can calculate how many time has passed since you started the timer until now
//and if you minus that to your timer duration you can obtain how many time is left to the timer to end
//and 60000 is the conversion value to transform it to minutes