I need to create new Date from a string in format: dd-M-yyyy
example:
var dateStr = '16-Sep-2012';
var date = new Date(dateStr);
However IE isn't very happy with it and considers date
value as NaN
.
Would somebody remend me or give me a reliable parser for that?
10x for your kind help, BR
I need to create new Date from a string in format: dd-M-yyyy
example:
var dateStr = '16-Sep-2012';
var date = new Date(dateStr);
However IE isn't very happy with it and considers date
value as NaN
.
Would somebody remend me or give me a reliable parser for that?
10x for your kind help, BR
- 1 code.google./p/datejs/wiki/APIDocumentation – mccannf Commented Oct 29, 2012 at 17:44
- 1 Check this out: depressedpress./javascript-extensions/dp_dateextensions – techfoobar Commented Oct 29, 2012 at 18:23
- 10x for your help, both of you – kidwon Commented Oct 30, 2012 at 10:55
1 Answer
Reset to default 5Use the Date.parse
function, and then call the new Date function on that variable. See a live example here.
var date = Date.parse('16-Sep-2012');
var formatted_date = new Date(date);
Using the jQuery globalization plugin, you can parse dates using Globalizaiton.parseDate. The plugin adds support for IE.