This seems like it should be simple but it has eluded me. I would like to convert my date string to a date object and filter how it is displayed.
I have a simple angular app and controller
myApp.controller('myAppCtrl', function($scope) {
$scope.MyDate = Date("2014-09-23T15:26:49.1513672Z");
})
I have JSON returned from the server and the date I am working with is a string in the above format
from the angular documentation about date filters
<span>{{1288323623006 | date:'medium'}}</span><br>
this works and the out put is: Oct 28, 2010 8:40:23 PM
When I try to use the filter on $scope.MyDate as follows:
{{MyDate | date:'medium'}}
the date is not formatted but looks like this: Wed Sep 24 2014 07:40:02 GMT-0700 (Pacific Daylight Time)
Ultimately I would like to bind an input text box to this value and filter it like this:
<input type="text" class="form-control" ng-model="MyDatee | date:'medium'"/>
I am hoping once i get the simple version working I can get my actual problem solved with the text input.
Here is a plunker with the above code