Skip to content

Commit a8275d3

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-33543-datetime-enhancements (#5272)
* DOCSP-33543-datetime-enhancements * DOCSP-33543-datetime-enhancements * DOCSP-33543-datetime-enhancements * DOCSP-33543-datetime-enhancements * DOCSP-33543-datetime-enhancements * DOCSP-33543-datetime-enhancements --------- Co-authored-by: jason-price-mongodb <[email protected]>
1 parent f908375 commit a8275d3

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

source/reference/method/Date.txt

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
======
2-
Date()
3-
======
1+
===================
2+
Date() and Datetime
3+
===================
44

55
.. default-domain:: mongodb
66

@@ -17,7 +17,14 @@ Date()
1717
.. method:: Date()
1818

1919
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).
2128

2229
Compatibility
2330
-------------
@@ -91,13 +98,11 @@ collection, the following operation inserts a document with the field
9198
- :update:`$currentDate`
9299
- :ref:`NOW aggregation variable usage <currentDate-example-agg>` to
93100
update with aggregation pipeline
94-
95101

96102
Return Date as a String
97103
~~~~~~~~~~~~~~~~~~~~~~~
98104

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:
101106

102107
.. code-block:: javascript
103108

@@ -107,11 +112,11 @@ Return Date as ``Date`` Object
107112
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
108113

109114
: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.
112117

113118
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:
115120

116121
.. code-block:: javascript
117122

0 commit comments

Comments
 (0)