Why does Mongo store my date as a string?

From Node.js I do

var startDate = new Date('2012-06-06');

Then I save it using mongodb native. It is stored as follows

'2012-06-05T14: 00: 00.000Z

+1
source share
3 answers

What you see is a representation of the JSON date: new date ('2012-06-06'). toJSON ();

https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/toJSON

+3
source

MongoDB stores dates in UTC, not as strings. Check BSON specifications.

http://bsonspec.org/#/specification

+4
source

. ( , - ISO-.) .

+1

Source: https://habr.com/ru/post/1670459/


All Articles