Moment.js - How to convert date string into date?
<p>Following up from my previous post: <a href="https://stackoverflow.com/questions/38154441/javascript-safari-new-date-with-strings-returns-invalid-date-when-typed">Javascript Safari: new Date() with strings returns invalid date when typed</a></p>

<p>I am using <strong>Moment.js</strong> to convert a date string into a date field based on user input in the text box. </p>

<p>This is to prevent the problem I described in the linked post for Safari and Firefox not able to render the date when Chrome is fine.</p>

<p>Here is the code snipper:</p>

<pre class="lang-js prettyprint-override"><code>var tempDate = moment(userInputFieldDate).format('DD-MM-YYYY');
alert(tempDate);
</code></pre>

<p>In Chrome, it does work fine (it use to work with the Javascript Date object too) but gives me the moment.js deprecation warning</p>

<blockquote>
  <p>Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to <a href="https://github.com/moment/moment/issues/1407" rel="noreferrer">https://github.com/moment/moment/issues/1407</a> for more info.
  Arguments: [object Object]
  Error</p>
</blockquote>

<p>On Firefox and Safari is just gives an <code>UNDEFINED DATE</code> in the alert window. So not entirely sure what should I be doing to convert the date string to a Date object. </p>

<p>Any suggestions on this issue?</p>