Regarding JavaScript new Date() and Date.parse() -
this code :
var exampledate='23-12-2010 23:12:00'; var date=new date(exampledate);//returns invalid date var date1=date.parse(exampledate);//returns nan
i want convert above string date. have written code have seen above.
this code running fine in ie
, opera
, date
variable returning me invalid date , date1
returning nan
in mozilla firefox
, should do?
above format supported in ie , chrome.
so try formats. following formats , there supporting browsers.
<script type="text/javascript"> //var datestring = "03/20/2008"; // mm/dd/yyyy [ie, ff] var datestring = "2008/03/20"; // yyyy/mm/dd [ie, ff] // var datestring = "03-20-2008"; // mm-dd-yyyy [ie, chrome] // var datestring = "march 20, 2008"; // mmmm dd, yyyy [ie, ff] // var datestring = "mar 20, 2008"; // mmm dd, yyyy [ie, ff] // initalize date object passing date string variable var mydate = new date(datestring); alert(mydate); </script>
Comments
Post a Comment