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.
HTML:
<li class="mark">Created:</li>
<li class="mark"> {{item.created_at | jsonDate : 'MM-dd-yyyy' }}"</li>
<li class="mark">Updated:</li>
<li class="mark"> {{item.updated_at | jsonDate : 'MM-dd-yyyy'}}</li>
Filter:
defaultPage.filter('jsonDate', ['$filter', function ($filter) {
return function (input, format) {
return (input) ? $filter('date')(parseInt(input.substr(6)), format) : '';
};
}]);