My date is a string in this format:
Dec 31, 1969 7:00:00 PM
I want to show a shorter date on the view so i do this with angular
<input ui-date="{ dateFormat: 'yy-mm-dd' }" ui-date-format ng-model="project.date" />
But then project.date is no longer the old format but the unix one (I think) :
1969-12-09T05:00:00.000Z
But i want to ouptput it in the previous format :
Dec 31, 1969 7:00:00 PM
How could i do this?
use Date filter, exp : {{yourDate | date:'medium' }} check this : http://docs.angularjs.org/api/ng.filter:date
You can do the following:
<input ui-date="{ project.date | date : 'medium'}" ui-date-format ng-model="project.date" />
in you html tag or in your ctrl
$scope.today = $filter('date')(project.date,''MMM d, y h:mm:ss a'');
make sure you dependent inject $filter to your ctrl