Articles → MONGODB → Isodate Function In Mongodb

Isodate Function In Mongodb






Purpose





What Is ISO 8601 Format?




[YYYY]-[MM]-[DD]T[hh]:[mm]:[ss].[SSS]Z




  1. YYYY → 4-digit year
  2. MM → 2-digit month
  3. DD → 2-digit day
  4. T → Separator indicating the start of the time component
  5. hh → 2-digit hour (24-hour format)
  6. mm → 2-digit minute
  7. ss → 2-digit second
  8. SSS → 3-digit millisecond
  9. Z → Indicates that the time is in UTC

Example




db.mycollection.insertOne({
    name: "Time 1",
    createdAt: ISODate("2023-06-03")
})

db.mycollection.insertOne({
    name: "Time 2",
    createdAt: ISODate("2023-06-03 12:23")
})





Output


Picture showing the output of Isodate Function In Mongodb



Posted By  -  Karan Gupta
 
Posted On  -  Tuesday, June 4, 2024

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250