title: Javascript Date in yyyy-mm-ddThh:mm:ss-offset not casting correctly
body: <p>I have a date like the following:</p>
  
  <blockquote>
    <p>2016-04-13T09:57:21-04</p>
  </blockquote>
  
  <p>I am trying to cast this to a javascript date:</p>
  
  <pre><code>event.timestamp = new Date(event.timestamp);
  </code></pre>
  
  <p>where event.timestamp is a string representation of the date. The problem is that this is set as converted to undefined. I am almost certain that my datetime is a valid ISO format. What am I doing wrong here?</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Some have noted that the datetime is not valid, and I agree that javascript does not consider it so, but I generate the datetime from a Scala API call</p>
  
  <p>using jodatime:</p>
  
  <p><code>DateTime.now()</code></p>
  
  <p>So this will generate a valid datetime (at least for scala). The -04 is the offset. I am not arguing that the date time is or is not valid in Javascript, because that is obvious. <strong>I am curious if there is a way to make it valid for javascript, because the jodatime date library seems pretty standard in Java and Scala and I am assuming there is a way to make it work with JavaScript.</strong></p>
  
  <p><strong>Edit 2</strong>
  Thriggle's answer is correct, but you cal also use Moment to get the date in a correct format:</p>
  
  <pre><code>moment(event.timestamp, "YYYY-MM-DD HH:mm Z").toDate();
  </code></pre>
  
  <p>moment can read a datetime in the format I have (2016-04-13T09:57:21-04)</p>