1
- ======
2
- Date()
3
- ======
1
+ ===================
2
+ Date() and Datetime
3
+ ===================
4
4
5
5
.. default-domain:: mongodb
6
6
@@ -13,7 +13,14 @@ Date()
13
13
.. method:: Date()
14
14
15
15
Returns a date either as a string or as a
16
- :ref:`document-bson-type-date` object.
16
+ :ref:`document-bson-type-date` object. The date can contain a date
17
+ and a time, known as a *datetime*.
18
+
19
+ The `BSON specification <http://bsonspec.org/#/specification>`_
20
+ states a ``Date`` object contains the *UTC datetime*. UTC is
21
+ *Coordinated Universal Time*. The UTC datetime stores an unsigned
22
+ 64-bit integer value, indicating the number of milliseconds after the
23
+ Unix epoch (January 1st, 1970 at 00:00:00 UTC).
17
24
18
25
Compatibility
19
26
-------------
@@ -87,13 +94,11 @@ collection, the following operation inserts a document with the field
87
94
- :update:`$currentDate`
88
95
- :ref:`NOW aggregation variable usage <currentDate-example-agg>` to
89
96
update with aggregation pipeline
90
-
91
97
92
98
Return Date as a String
93
99
~~~~~~~~~~~~~~~~~~~~~~~
94
100
95
- To return the date as a string, use the ``Date()`` method, as in the
96
- following example:
101
+ To return the date as a string, use the ``Date()`` method. For example:
97
102
98
103
.. code-block:: javascript
99
104
@@ -103,11 +108,11 @@ Return Date as ``Date`` Object
103
108
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104
109
105
110
:binary:`~bin.mongosh` wraps objects of
106
- :ref:`document-bson-type-date` type with the ``ISODate`` helper;
107
- however , the objects remain of type :ref:`document-bson-type-date`.
111
+ :ref:`document-bson-type-date` type with the ``ISODate`` helper.
112
+ However , the objects are :ref:`document-bson-type-date` types .
108
113
109
114
The following example uses ``new Date()`` to return
110
- :ref:`document-bson-type-date` object with the specified UTC datetime.
115
+ a :ref:`document-bson-type-date` object with the specified UTC datetime:
111
116
112
117
.. code-block:: javascript
113
118
0 commit comments