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