Javascript parse date from toLocaleDateString for known locale
<h2>Background</h2>

<p>In my application I want to format dates according to the user's locale. If the user modifies the date, I want to be able to parse it back into a javascript Date object.</p>

<h2>Problem</h2>

<p>I wonder if it's possible to parse a date from a locally formatted string using javascript?</p>

<p>Please consider the following snippet:</p>

<pre><code>new Date(2016, 0, 1).toLocaleDateString('ar');
&gt;&gt;"١‏/١‏/٢٠١٦"
</code></pre>

<p>If I want to parse that string back to a valid date how would I go about that? </p>

<p>The following will not work: </p>

<pre><code>new Date(new Date(2016, 0, 1).toLocaleDateString('ar'));
&gt;&gt;Invalid Date
</code></pre>

<p>I also experimented with using <a href="http://momentjs.com/" rel="nofollow">momentjs</a> but was unable to find a working way there.</p>

<pre><code>//change global locale
moment.locale('ar-sa');

moment().format('L');
&gt;&gt;"١٥/٠٦/٢٠١٦"

moment(new moment().format('L'))._d;
&gt;&gt;Invalid Date
</code></pre>

<p>Or is there some other/better way to think around issues like this?</p>