admin管理员组

文章数量:1326066

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.

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.

Share Improve this question edited May 9, 2017 at 8:11 Satpal 133k13 gold badges167 silver badges170 bronze badges asked May 9, 2017 at 8:02 Lavanya D.Lavanya D. 5112 gold badges6 silver badges16 bronze badges 1
  • Try: d = "2017-04-12T21:46:20Z"; d=d.replace(/[T]/, ' ');d=d.replace(/[Z]/, ''); – TheChetan Commented May 9, 2017 at 8:07
Add a ment  | 

3 Answers 3

Reset to default 5

Try to:

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

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

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

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

本文标签: javascriptFormatting timestamp in Angular JSStack Overflow