In MongoDB, the Date() method returns a date either as a string or as a Date object.
- When you call it as
Date(), it returns the current date as a string in themongoshell. - When you call it as
new Date(), it returns the current date as a Date object.
You can also provide a specific date as an argument to new Date(), so that it uses that date.