Converting JSON date(s) in AngularJS
<p>I would like to convert dates retrieved from JSON string and format them yyyy-MM-dd. I am using the code below to format my the dates but oddly the dates are returning "12-31-1969" when the JSON string is for example "created_at": "2016-01-26T09:52:31Z" therefore the correct string would be 01-26-2016 not 12-31-1969. </p>

<p>HTML: </p>

<pre><code>&lt;li class="mark"&gt;Created:&lt;/li&gt;
&lt;li class="mark"&gt; {{item.created_at | jsonDate : 'MM-dd-yyyy' }}"&lt;/li&gt;
&lt;li class="mark"&gt;Updated:&lt;/li&gt;
&lt;li class="mark"&gt; {{item.updated_at | jsonDate : 'MM-dd-yyyy'}}&lt;/li&gt;
</code></pre>

<p>Filter: </p>

<pre><code> defaultPage.filter('jsonDate', ['$filter', function ($filter) {
        return function (input, format) {
           return (input) ? $filter('date')(parseInt(input.substr(6)), format) : '';
    };
}]);
</code></pre>