- Reference >
- mongo Shell 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. The mongo shell wraps the Date object with the ISODate helper.
- new Date("<YYYY-mm-dd>") returns the specified date string ("<YYYY-mm-dd>") as a Date object. The mongo shell wraps the Date object with the ISODate helper.
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.
Thank you for your feedback!
We're sorry! You can Report a Problem to help us improve this page.