I'm trying to clear some of the local storage items after 2 minutes using this code
I'm saving current time in the variable like :
let time_now = (new Date()).getTime();
localStorage.setItem('otp_save_time', time_now);
localStorage.setItem('set_otp', value);
Now i'm checking the current time with the saved time and clearing the item if time is greater than 2 minutes, but it is not clearing the item.
let time_now = (new Date()).getTime();
if((time_now - saved_time) > 2 * 60 * 1000) {
localStorage.removeItem('set_otp');
localStorage.removeItem('otp_save_time');
}