title: How to handle datetime between php (Laravel api) and javascript (AngularJS)
body: <p>I'm utterly stuck trying to make php api exchange dates with angular frontend.</p>
  
  <p>From PHP to JS I seem to have it sorted. Since Laravel handles dates through Carbon I just added <code>\Carbon\Carbon::setToStringFormat('c');</code> to app.php which makes dates come out in  ISO 8601.</p>
  
  <p>PHP example:</p>
  
  <blockquote>
    <p>2015-02-04T00:53:51+02:00</p>
  </blockquote>
  
  <p>AngularJS date filter also seems to understand this format well and even reads the timezone correctly.</p>
  
  <p>What I have yet to get working is posting JS date objects back to PHP api.</p>
  
  <p>JS example:</p>
  
  <blockquote>
    <p>2015-02-05T13:00:00.000Z</p>
  </blockquote>
  
  <p>Javascript date format ends up with milliseconds added to the string and in default configuration Carbon complains about trailing data.</p>
  
  <p>Also browsers seem to automatically translate my dates into UTC time.</p>
  
  <p>Manually using <code>new Carbon('jsDateString')</code> seems to work at first but on closer inspection timezone data is not considered.</p>
  
  <p>So my question is what would be the best and most automatic solution to send dates back to Laravel php api from AngularJS frontend?</p>