title: Format MomentJS to Rails DateTime
body: <p>How do you format <code>moment()</code> to Rails datetime?</p>
  
  <p>Im using <a href="https://github.com/Hacker0x01/react-datepicker" rel="nofollow noreferrer">react-datepicker</a> and Rails 5 as the back end.</p>
  
  <p><strong>React:</strong></p>
  
  <pre><code>let newDate = this.state.startDate.format('YYYY-MM-DD HH:mm')
  console.log(newDate); #=&gt; 2016-10-11 08:46
  </code></pre>
  
  <p>Looking at the <a href="http://momentjs.com/" rel="nofollow noreferrer">momentjs formats</a>, I see nothing close to rails datetime format ie: <code>Mon, 10 Oct 2016 15:16:29 UTC +00:00</code></p>
  
  <p>The aim is to pass <code>newDate</code> as <code>params</code> to a rails controller: <code>params[:new_date]</code></p>
  
  <p><strong>Update:</strong></p>
  
  <p><a href="https://stackoverflow.com/users/3218479/cema-sp">cema-sp</a>'s answer was the final part to my answer but I was getting errors. To solved this:</p>
  
  <pre><code># JS:
  let newDate = this.state.startDate.format(); # no format type
  
  # Controller:
  DateTime.strptime(params[:new_date], '%Y-%m-%dT%H:%M:%S%z')
  </code></pre>