IE javascript Engine rending NaN when conveting string to date -
this question has answer here:
i have string consisting of '2013-04-05t00:00:00'. when embed below code js file chakra (ie javascript engine) barfs. when run ie console barfs. every other browser have tested on fine. how can make below statement browser agnostic?
var targetdate = new date('2013-04-05t00:00:00'); alert(targetdate);
edit
ie version 7,8 not run
runs fine in ie 9+
edit#2
the reason doesn't work ie 8,7 not support iso date times. either need generate date object non iso date time stamp.
i suggest using date.js fix up these date parsing issues. work in ie8:
<html> <body> <script src="http://www.datejs.com/build/date.js" type="text/javascript"></script> <script> var targetdate = date.parse('2013-04-05t00:00:00'); alert(targetdate); </script> </body> </html>
note, you'll have use date.parse
method rather date()
constructor.
Comments
Post a Comment