Example 1 — Sample Data
Imagine three events on the same day, stored as BSON dates in UTC. We save them in a collection named events.
db.events.insertMany([
{ _id: 1, name: "Standup", at: ISODate("2024-06-15T08:15:00Z") },
{ _id: 2, name: "Demo", at: ISODate("2024-06-15T14:00:00Z") },
{ _id: 3, name: "Deploy", at: ISODate("2024-06-15T23:30:00Z") }
]); How the Data Is Stored in MongoDB
After the insert, MongoDB keeps three documents in events. Run find() to see them:
db.events.find() Read those documents like this:
| Field in MongoDB | Example | Plain English |
|---|---|---|
_id | 1 | Event id for this lesson |
name | "Standup" | Event label |
at | ISODate("…T08:15:00Z") | Event time as a BSON Date (UTC) |
UTC day clock (hour hand):
00 08 14 23
|---|---|---|
^ ^ ^
Standup Demo Deploy
$hour("$at") → 8, 14, 23 How It Works
- Insert once.
insertManyadds three event documents with real Date values. - MongoDB stores Date, not string.
ISODate(...)becomes a BSON Date—required by$hour. - find() shows the same shape. What you inserted is what you get back—ready for
$hournext.

