Yehudi Mikhael
Yehudi Mikhael

Reputation: 69

Format date with angularjs

I am the problem in defining the output of "date" . I would like that the past value for the variable is dd / mm / yyyy. The problem is who is going 2016-05-11T19 : 23: 34.399Z "

Upvotes: 2

Views: 37

Answers (2)

Zohaib Ijaz
Zohaib Ijaz

Reputation: 22875

Add a date filter and required format.

 {{dt | date: 'dd/MM/yyyy'}}

http://plnkr.co/edit/DDDepd8uwpzdBlGgxpuk?p=preview

@Yehudi Mekhael, if you want dt to be in that format and pass as parameter then you can do something.

var dt = $filter('date')(dt, 'MMM dd yyyy');

But now dt is not a date object, it's a string.

Upvotes: 2

Simon Schüpbach
Simon Schüpbach

Reputation: 2683

Just use like this

{{dt | date:'dd/MM/yyyy' }}

Upvotes: 2

Related Questions