1- ======
2- Date()
3- ======
1+ ===================
2+ Date() and Datetime
3+ ===================
44
55.. default-domain:: mongodb
66
@@ -13,7 +13,14 @@ Date()
1313.. method:: Date()
1414
1515 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).
1724
1825Compatibility
1926-------------
@@ -87,13 +94,11 @@ collection, the following operation inserts a document with the field
8794 - :update:`$currentDate`
8895 - :ref:`NOW aggregation variable usage <currentDate-example-agg>` to
8996 update with aggregation pipeline
90-
9197
9298Return Date as a String
9399~~~~~~~~~~~~~~~~~~~~~~~
94100
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:
97102
98103.. code-block:: javascript
99104
@@ -103,11 +108,11 @@ Return Date as ``Date`` Object
103108~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104109
105110: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 .
108113
109114The 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:
111116
112117.. code-block:: javascript
113118
0 commit comments