db.collection.insert([{'_id': ObjectId('5f1ebc633286f41a3079f724'),
'updateTime': new Date(2020, 7, 27, 19, 37, 7, 616000),
}])
Returns a date either as a string or as a Date object.
-
Date()
returns the current date as a string in themongo
shell. -
new Date()
returns the current date as a Date object. Themongo
shell wraps the Date object with theISODate
helper. TheISODate
is in UTC.
You can specify a particular date by passing an ISO-8601 date string with a year within the inclusive range 0
through 9999
to the new Date()
constructor or the ISODate()
function. These functions accept the following formats:
-
new Date("<YYYY-mm-dd>")
returns theISODate
with the specified date. -
new Date("<YYYY-mm-ddTHH:MM:ss>")
specifies the datetime in the client’s local timezone and returns theISODate
with the specified datetime in UTC. -
new Date("<YYYY-mm-ddTHH:MM:ssZ>")
specifies the datetime in UTC and returns theISODate
with the specified datetime in UTC. -
new Date(<integer>)
specifies the datetime as milliseconds since the Unix epoch (Jan 1, 1970), and returns the resultingISODate
instance.
网友评论