I am trying to check if a timestamp I have in local storage is more than 6 hours old, I don't believe my logic is correct. Here is what I have so far.
function checkBasket() {
const basket = localStorage.getItem('user_basket');
if (basket) {
var sixHours = 5 * 60 * 60 * 1000;
return ((new Date) - JSON.parse(basket).timestamp) < sixHours;
}
return false;
}
So I am trying to get this function to return true if the localstorage basket.timestamp is less than 6 hours old, otherwise false.