6

I am displaying date in this format using angular

{{ date }} ,date:\'MM-dd-yyyy HH:MM:ss\

how to display like Jan-dd-yyyy using angular

Is there any dirct way to do using angular js- (Using normal jquery i am able to do)

2

4 Answers 4

11

use Angular filter of date.

{{date  | date:'MM-dd-yyyy HH:MM:ss'}}

See the following link.

http://docs.angularjs.org/api/ng.filter:date

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

1 Comment

it should be HH:mm:ss
2

Well,

according to the docs, you have a builtin filter in angular, called date:

<p>{{Date.now() | date:'yyyy'}}

would render to:

<p>2013</p>

The yyyyin this case can be any format string documented. In the example you gave, this would be:

{{date | date: 'MMM-dd-yyyy'}} # => "Jan-21-2013" (if date was a date object for this day)

Comments

2

For custom date:

$scope.user.dob = new Date('1980', '12' ,'10');  // controller code

 {{user.dob | date : 'MMM-dd-yyyy'}}  // Dec-10-1980

For current date:

 $scope.user.current= new Date();  // controller code

 {{user.current | date : 'MMM-dd-yyyy'}}  // Current date in given format

Comments

1

Try this

 {{ date }} ,date:\'MMM-dd-yyyy HH:MM:ss\

1 Comment

Should be HH:mm:ss, you have months instead of minutes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.