Date from MongoDB prints as "date": "2011-05-12T13: 51: 33Z"

Why do I get "T" and "Z" on the date when I extract it from MongoDB and convert it to JSON using Rails3?

"date":"2011-05-12T13:51:33Z"

thank

Fetch:

@bs = coll.find("headers.from" => email, "date" => {"$gte" => initial_date, "$lte" => Time.now.utc})

Insert:

date  :  { type: Date, default: Date.now }
+3
source share
1 answer

This is the date and time in ISO8601 format. "T" separates the date from time, and "Z" indicates that the date is UTC (GMT). MongoDB does not support the Date (only) type, instead everything is converted to a timestamp.

You can go into the mongo console and run a query by which you will see the date (and time) fields that are stored as ISODate ("2011-05-12T13: 51: 33Z").

+3
source

All Articles