vishnu
vishnu

Reputation: 4599

angular converting the date in dd/mm/yyyy format

i have date format getting from server in the following way,

"tranDate":"2015-11-29T18:30:00.000Z"

I tried to displaying the date in the view like this, but the date is showing - 30/11/2015(i.e it should be 29/11/2015).

<td>{{stmt.tranDate | date:'dd/MM/yyyy'}}</td> 

what could be the problem?

Upvotes: 3

Views: 2185

Answers (5)

birkett
birkett

Reputation: 10101

As of Angular 1.3 you can specify that you want the time to be interpreted in UTC.

<td>{{stmt.tranDate | date:'dd/MM/yyyy' : 'UTC'}}</td> 

Upvotes: 2

Sheetal
Sheetal

Reputation: 1366

Try this {{stmt.tranDate | date:"dd/MM/yyyy": 'UTC'}}

Upvotes: 2

Matteo Cardellini
Matteo Cardellini

Reputation: 896

You should try with moment.js and with tha angular-moment directive

Upvotes: 1

katmanco
katmanco

Reputation: 1212

You can apply this format then you have the desired date .

$scope.datex="2015-11-29T18:30:00.000Z";
  <p>{{datex | date:'d/M/yyyy'}}</p>

Upvotes: 1

Egan Wolf
Egan Wolf

Reputation: 3573

Your time is in Zulu time (Z in the end). Angular displays time in your local time.

Upvotes: 4

Related Questions