Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You want to use the <a href="http://code.google.com/p/datejs/wiki/APIDocumentation#parseExact" rel="nofollow">Date.parseExact</a> method. For some reason it works while the normal parse does not. Also you don't need to pass the format option wrapped in an object.</p> <p>According to the spec Date.parse is not supposed to take a format option so that is probably why.</p> <pre><code>// Parses correctly var dateWithFormat = Date.parseExact('01062012', 'ddMMyyyy'); </code></pre> <p>I have also updated the <a href="http://jsfiddle.net/VBZJx/" rel="nofollow">jsfiddle</a> to be sure.</p> <h2>Update</h2> <p>I think the issue is that the parser <a href="http://code.google.com/p/datejs/source/browse/trunk/src/parser.js#921" rel="nofollow">hard-codes</a> a bunch of simple formats and those override the localization setting for the date, month and year order in some cases. If you put the following before where you use Date it will fix your issue.</p> <pre><code>Date.Grammar._formats = Date.Grammar.formats([ "\"yyyy-MM-ddTHH:mm:ssZ\"", "yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ssz", "yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mmZ", "yyyy-MM-ddTHH:mmz", "yyyy-MM-ddTHH:mm", "ddd, MMM dd, yyyy H:mm:ss tt", "ddd MMM d yyyy HH:mm:ss zzz", "ddMMyyyy", "MMddyyyy", "ddMyyyy", "Mddyyyy", "dMyyyy", "Mdyyyy", "yyyy", "dMyy", "Mdyy", "d" ]); </code></pre> <p>This is not pretty but it is definitely shorter than listing all of the possible options, if only by a little bit. If you can find a less quirky Date library that might be a better option.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload