LocalStorage With Timestamp ?
I love learning about technology and sharing that with others
Introduction
Problem Statement
we want to store some information on the localStorage and then we want to show the user when is the last time this information is updated, and once that is done we want to give user the functionality to again refresh and update the localStorage information and current timestamp
Solution
Create an object with data and timestamp
Store this in the Local Storage
Read from localStorage if Required parse the data and show the data and timestamp
if the user refresh update the data and the current timestamp
var object = {value: "value", timestamp: new Date().getTime()}
localStorage.setItem("key", JSON.stringify(object));
var object = JSON.parse(localStorage.getItem("key")),
dateString = object.timestamp,
now = new Date().getTime().toString();
compareTime(dateString, now); //to implement

