i'm doing conversion date string , using in sessionstorage. first this:
sessionstorage.currentdate = mydate.tojson();
and this:
if (sessionstorage.currentdate ) { mydate = new date(sessionstorage.currentdate); }
the problem mydate.tojson()
function in ie9+ returns "2013-05-06t22:00:00.000z"
in ie8 returns "2013-05-06t22:00:00z"
missing decimal part @ end. fact in ie8 failing subsequent re-conversion date (the result new date(sessionstorage.currentdate)
nan
)
any idea why happening , how make code work ie8+?
update:
i tried replace string in debug, , turns out none of 2 strings works. seems problem of new date(sessionstorage.currentdate)
not recognizing format (wich utc)
prior es5, parsing of dates entirely implementation dependent. ie 8 (and lower) won't parse iso 8601 format specified in es5, parse yourself:
// parse iso format date 2013-05-06t22:00:00.000z function datefromiso(s) { s = s.split(/\d/); return new date(date.utc(s[0], --s[1]||'', s[2]||'', s[3]||'', s[4]||'', s[5]||'', s[6]||'')) }
assumes string utc.
Comments
Post a Comment