JavaScript Date mismatch after being stored as string -
this question has answer here:
- javascript date object comparison 4 answers
i cannot figure out why ls_a === a
returning false
in code below. seems when convert date string , date, being lost, what??
jsfiddle: http://jsfiddle.net/s6accbax/
var = new date(); localstorage.a = a.gettime(); ls_a = new date(parseint(localstorage.a)); console.log(a); // fri jun 12 2015 22:12:34 gmt-0600 (mdt) console.log(ls_a); // fri jun 12 2015 22:12:34 gmt-0600 (mdt) console.log(ls_a === a); // returns false!?!?! console.log(ls_a.gettime() === a.gettime()); // returns true expected
duplicate of: javascript date object comparison
this because ls_a
different object a
when call .gettime()
getting string isn't compared object
Comments
Post a Comment