title: Date return NAN in IE
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3020508/ie-javascript-date-parsing-error">IE JavaScript date parsing error</a>  </p>
  </blockquote>
  
  
  
  <p>This code working fine in chrome and firefox but it didn't work in IE and safari. It return NAN in IE and invalid date in safair.</p>
  
  <pre><code>var date = new Date("2012-10-17T08:15:19.500-05:00");
  var now = new Date();
  var difference = now - date;
  
  document.write( "Date: " + date.toLocaleString() + "&lt;br/&gt;");
  document.write( "Now: " + now.toLocaleString() + "&lt;br/&gt;");
  document.write( "Difference: " + differenceToString(difference) );
  
  function differenceToString(milliseconds) {
      var seconds = milliseconds / 1000;
      var numyears = Math.floor(seconds / 31536000);
      var numdays = Math.floor((seconds % 31536000) / 86400);
      var numhours = Math.floor(((seconds % 31536000) % 86400) / 3600);
      var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
      var numseconds = Math.floor((((seconds % 31536000) % 86400) % 3600) % 60);
      return numyears + " years, " + numdays + " days, " + numhours + " hours, " + numminutes + " minutes, " + numseconds + " seconds";
  }
  </code></pre>
  
  <p><a href="http://jsfiddle.net/RYS3R/" rel="nofollow noreferrer">http://jsfiddle.net/RYS3R/</a></p>
  
  <p>Any idea would be great help.</p>
  
  <p>Thanks</p>