1

The date field in my mongodb database is saved under the following format

        "$date": "2012-01-05T19:47:56.474Z"

But somehow mongoose returns it as

        date: Wed, 04 Jan 2012 19:14:33 GMT

Why does the format change, is it something i am doing in the query ?

andrei
  • 8,252
  • 14
  • 51
  • 66

2 Answers2

2

That's the way a standard JavaScript Date object is formatted when printing.

You can print it out in ISO format using something like this: How do I output an ISO 8601 formatted string in JavaScript?

Or you might try using a javascript date library for formatting such as: http://arshaw.com/xdate/#Formatting

Community
  • 1
  • 1
Eve Freeman
  • 32,467
  • 4
  • 86
  • 101
1

The former format is ISO 8601, the latter looks like Date.toString in JavaScript.

These are just different textual representations of the same date, stored internally using some portable format like Unix time. Everything is fine.

Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • I know it's fine it's just that I'm using timeago the jquery plugin and it seems to only work for the first time format :/ And trying to fix that i came across this – andrei Jan 05 '12 at 22:34