Articles → MONGODB → Date And Timestamp Function In Mongodb

Date And Timestamp Function In Mongodb






Purpose





Example




db.DateTimeCollection.insertOne({
  Date: new Date(),
  Time: new Timestamp()
})


Picture showing inserting the date and time using the Date and Timestamp function
Click to Enlarge



Picture showing the value of date and time field inserted earlier
Click to Enlarge



Picture showing the output of the getTimestamp() function
Click to Enlarge




Posted By  -  Karan Gupta
 
Posted On  -  Monday, April 3, 2023

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250