Where does the "T00:00:00Z" come from?

In the $map (aggregation) documentation, why does an input in

db.temperatures.insertMany([
  { "_id" : 1, "date" : ISODate("2019-06-23"), "tempsC" : [ 4, 12, 17 ] },
  { "_id" : 2, "date" : ISODate("2019-07-07"), "tempsC" : [ 14, 24, 11 ] },
  { "_id" : 3, "date" : ISODate("2019-10-30"), "tempsC" : [ 18, 6, 8 ] }
])
 db.temperatures.aggregate( [
   { $addFields:
      {
         "tempsF":
            { $map:
               {
                  input: "$tempsC",
                  as: "tempInCelsius",
                  in: { $add: [ { $multiply: [ "$$tempInCelsius", 9/5 ] }, 32 ] }
               }
            }
       }
    }
] )

will return this result?

{ "_id" : 1, "date" : ISODate("2019-06-23T00:00:00Z"), "tempsC : [ 4, 12, 17 ], "tempsF" : [ 39.2, 53.6, 62.6 ] }
{ "_id" : 2, "date" : ISODate("2019-07-07T00:00:00Z"), "tempsC" : [ 14, 24, 11 ], "tempsF" : [ 57.2, 75.2, 51.8 ] }
{ "_id" : 3, "date" : ISODate("2019-10-30T00:00:00Z"), "tempsC" : [ 18, 6, 8 ], "tempsF" : [ 64.4, 42.8, 46.4 ] }

Where does the “T00:00:00Z” in “ISODate” come from?

Hello @h951115951115 ,

ISODate() is a helper function that’s built into MongoDB and it provides output in global standardised ISO 8601 date format that is “YYYY-MM-DDTHH:mm:ssZ”. Here “T” separates the date portion from the time-of-day portion. The Z on the end means UTC (that is, an offset-from-UTC of zero hours-minutes-seconds). Also, that these default to 00:00:00 because time was not defined.

This document can be used as reference.

Best regards,
Tarun

3 Likes

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.