- Reference >
mongoShell Methods >- Object Constructors and Methods >
- Date()
Date()¶
-
Date()¶ Returns a date either as a string or as a Date object.
Date()returns the current date as a string.new Date()returns the current date as a Date object. Themongoshell wraps the Date object with theISODatehelper.new Date("<YYYY-mm-dd>")returns the specified date string ("<YYYY-mm-dd>") as a Date object. Themongoshell wraps the Date object with theISODatehelper.
Behavior¶
Internally, Date objects are stored as a 64 bit integer representing the number of milliseconds since the Unix epoch (Jan 1, 1970), which results in a representable date range of about 290 millions years into the past and future.