Lavanya D.
Lavanya D.

Reputation: 511

Formatting timestamp in Angular JS

Updated at : {{res.updated_at}}

Value: {"updated_at":"2017-04-12T21:46:20Z"}

I need to change this 2017-04-12T21:46:20Z to 2017-04-12 21:46:20 by removing T and Z. Please help how to achieve this. The code is in angular js.

Upvotes: 4

Views: 7002

Answers (3)

Sventies
Sventies

Reputation: 2776

"2017-04-12T21:46:20Z".split("T").join(" ").split("Z").join("")

Upvotes: -1

mattmess1221
mattmess1221

Reputation: 4454

I don't know if it's specific to angular, but this formatting pattern should work.

yyyy-MM-dd hh:mm:ss

This should format the date as 2017-04-12 21:46:20

Upvotes: 1

Viet
Viet

Reputation: 3409

Try to:

{{res.updated_at| date : 'yyyy-MM-dd HH:mm:ss'}}

Detail format at: https://docs.angularjs.org/api/ng/filter/date

Upvotes: 5

Related Questions