JavaScript Date mismatch after being stored as string -


this question has answer here:

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

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -