2

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?

2
  • not clear what format you want where. Create a live demo. Commented Apr 1, 2013 at 21:50
  • I want this one: Dec 31, 1969 7:00:00 PM I/O and just printed different on the view Commented Apr 1, 2013 at 21:57

2 Answers 2

2

use Date filter, exp : {{yourDate | date:'medium' }} check this : http://docs.angularjs.org/api/ng.filter:date

Sign up to request clarification or add additional context in comments.

Comments

1

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

To see more of date formats here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.