0

I want to use angular date pipe, but it cause error, because when I get date from my Mongoose it's in this bad format 2016-02-29T23:00:00.000Z and Angular pipe cant handle it. I set up schema in Mongoose, but it didn't help. It's there any more elegant way, ideally on Mongoose side, how to convert this to date object or timestamp?

Thank.

António Campos
  • 171
  • 2
  • 12
Daniel Suchý
  • 1,822
  • 2
  • 14
  • 19

1 Answers1

0

As mentioned in this answer, since there is no standard JSON representation of dates, send a seconds-from-Unix-epoch number, or something else from the server that can easily be converted into a JavaScript Date object. I.e., when you receive the data back from the server, convert all of the date strings into Date objects. Then you can use the Angular DatePipe.

Community
  • 1
  • 1
Mark Rajcok
  • 362,217
  • 114
  • 495
  • 492