Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To simplify a little bit the error is because the format used by IE to store dates is not the same used by, for example, Chrome (and the one you're using to manually parse and format the date). It's allowed by the <a href="http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf" rel="nofollow noreferrer">standard</a>, what is required is the browser can parse the format produced by itself (see <strong>§15.9.4.2</strong>).</p> <p>Usually to work directly with date format is not a good idea, not only because browser specific implementation but because of globalization (this is especially true for a web application with a virtual world wide audience). In practice what I mean is <strong>DO NOT EVER DO</strong> something like this (in <a href="https://stackoverflow.com/a/25865621/1207195">this post</a> I try to explain the reasons):</p> <pre><code>d.getMonth() + 1 + " " + d.getDate() + " " + d.getFullYear() </code></pre> <p>or this:</p> <pre><code>d.getMonth() + 1 + "-" + d.getDate() + "-" + d.getFullYear() </code></pre> <p>Few <em>exceptions</em> to this rule:</p> <ul> <li>You're formatting that string for end-user (and only <strong>if you don't care about her date format</strong>, please note that with that code you're assuming MDY order and a specific separator).</li> <li>You'll use that string by yourself and you'll parse it with another handmade parser (you won't use <code>Date.parse()</code>) because it's locale and browser dependent.</li> <li>You're writing your own library to manage dates.</li> </ul> <p>The only format you're sure every browser (that supports ECMAScript 5) will read is ISO 8601 <code>YYYY-MM-DDTHH:mm:ss.sssZ</code> (see <strong>§15.9.1.15</strong>) so in your case you should change your custom parsing/formatting to that. For older browser there is not a clear rule (that's why we need a library). The standard says at <strong>§15.9.4.2</strong> that:</p> <blockquote> <p>If the String does not conform to that format [ISO 8601] the function may fall back to any <strong>implementation-specific heuristics or implementation-specific date formats</strong>.</p> </blockquote> <p><em>(emphasis is mine)</em></p> <p>Take a look to <a href="https://stackoverflow.com/questions/2587345/javascript-date-parse?rq=1">this</a> and <a href="https://stackoverflow.com/questions/4321270/regarding-javascript-new-date-and-date-parse">this</a> posts on SO for other details (or <a href="http://javascript.info/tutorial/datetime-functions" rel="nofollow noreferrer">this little tutorial</a> about dates).</p> <p>What I suggest, if you work with dates across browsers and locales, is to use a good library to abstract all this details. I found <a href="http://mattkruse.com/javascript/date/date.js" rel="nofollow noreferrer">this one</a> is pretty strong and easy to use. If you want a widely used almost complete library take a look to <a href="http://momentjs.com/" rel="nofollow noreferrer">moment.js</a> too.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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