I need to parse dates in JavaScript. The format is
[2 digits day]/[2 digits month]/[4 digits year] [2 digits hour (24 mode)]:[2 digits minute]
For example, 16/02/2013 21:00
But if I do new Date('16/02/2013 21:00').toString()
, it gives 'Wed Apr 02 2014 21:00:00 GMT+0200 (Hora de verano romance)'
.
I guess that's because my dates don't follow IETF RFC 2822 Date and Time Specification. Then, I should convert my string, and I want to convert it to the most similar compliant format (because it should be easier to convert). But http://tools.ietf.org/html/rfc2822#page-14 is hard to understand, so I don't know which is the most similar format.
Is there a list with examples of the allowed formats?
This question seems to be asking "What formats are required to be parsed by ECMSCript implementations".
Prior to ECMAScript Ed 5 (2011), parsing was entirely implementation dependent. The formats that ECMAScript implementations are required to parse can be summarised as:
Parsing of any other format remains implementation dependent and there are differences, so the general rule is "don't use the built-in parser".
MSDN has several examples of valid date formats:
Gotchas
There's a matrix of cross-browser inconsistencies as well.
References
Same Markup: Writing Cross-Browser Code – IEBlog
Loading Javascript files in parallel – Kristoffer's tidbits