JavaScript Date NaN issue in IE? -
i facing problem while displaying date in ie, below json structure trying display instoredate , firstmarkdowndate dates in ui. working fine in ff , chrome facing issues while coming ie. in ie showing nan.
"data":[ { "id": "123", "indate": [ 2012, 12, 17 ] } ]
i using below date format function format date before displaying.
formatdate: function(longdate) { var d = new date(longdate); return ('0' + (d.getmonth()+1)).slice(-2) + '/' + ('0' + (d.getdate())).slice(-2) + '/' + d.getfullyear(); } formatdate(data.indate);
you're passing array date
constructor cause of problems. arrays (as objects) stringified , parsed as-a-string when fed date
constructor - yet ie not recognize format "2012,12,17"
valid date while chrome does.
instead, should pass 3 single values separately:
var date = new date(longvalue[0], longvalue[1], longvalue[2]);
Comments
Post a Comment