I saved the date for local storage as below.
JS:
var currentTime = new Date();
localStorage.time = currentTime;
When I try to get it later using ...
var timeObj = new Date(localStorage.time);
var checkInDayOfMonth = timeObj.getUTCDate();
timeObj will not have the correct datetime, instead it will have the current time, as if it were ignoring the parameters of the time that I am sending.
I use getUTCDate to get the day of the month. If today's value is different from what is in the repository, I know this is a new day.
Opening the Google Chrome Inspector shows the date stored in localStorage in this format:
Wed Dec 11 2013 22:17:45 GMT-0800 (PST)
Is this not an acceptable format for a date constructor?
How can I properly store and return dates from localStorage?