This version of the documentation is archived and no longer supported.


On this page



The $currentDate operator sets the value of a field to the current date, either as a Date or a timestamp. The default type is Date.

The $currentDate operator has the form:

{ $currentDate: { <field1>: <typeSpecification1>, ... } }

<typeSpecification> can be either:

  • a boolean true to set the field value to the current date as a Date, or
  • a document { $type: "timestamp" } or { $type: "date" } which explicitly specifies the type. The operator is case-sensitive and accepts only the lowercase "timestamp" or the lowercase "date".

To specify a <field> in an embedded document or in an array, use dot notation.


If the field does not exist, $currentDate adds the field to a document.


Consider the following document in the users collection:

{ _id: 1, status: "a", lastModified: ISODate("2013-10-02T01:11:18.965Z") }

The following operation updates the lastModified field to the current date, the "" field to the current timestamp as well as updating the status field to "D" and the "cancellation.reason" to "user request".

   { _id: 1 },
     $currentDate: {
        lastModified: true,
        "": { $type: "timestamp" }
     $set: {
        status: "D",
        "cancellation.reason": "user request"

The updated document would resemble:

   "_id" : 1,
   "status" : "D",
   "lastModified" : ISODate("2014-09-17T23:25:56.314Z"),
   "cancellation" : {
      "date" : Timestamp(1410996356, 1),
      "reason" : "user request"