Skip to content

Commit dbd7e91

Browse files
committed
DOCSP-43158: carbon date values db query results
1 parent 7551f76 commit dbd7e91

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

docs/eloquent-models/model-class.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ type, to the Laravel ``datetime`` type.
216216
To learn more, see `Attribute Casting <https://laravel.com/docs/{+laravel-docs-version+}/eloquent-mutators#attribute-casting>`__
217217
in the Laravel documentation.
218218

219-
This conversion lets you use the PHP `DateTime <https://www.php.net/manual/en/class.datetime.php>`__
220-
or the `Carbon class <https://carbon.nesbot.com/docs/>`__ to work with dates
219+
This conversion lets you use the PHP `DateTime
220+
<https://www.php.net/manual/en/class.datetime.php>`__ class to work with dates
221221
in this field. The following example shows a Laravel query that uses the
222222
casting helper on the model to query for planets with a ``discovery_dt`` of
223223
less than three years ago:
@@ -226,6 +226,13 @@ less than three years ago:
226226

227227
Planet::where( 'discovery_dt', '>', new DateTime('-3 years'))->get();
228228

229+
.. note:: Carbon Date Class
230+
231+
Starting in {+odm-long+} v5.0, ``UTCDateTime`` BSON values in MongoDB
232+
are returned as `Carbon <https://carbon.nesbot.com/docs/>`__ date
233+
classes in query results. The {+odm-short+} applies the default
234+
timezone when performing this conversion.
235+
229236
To learn more about MongoDB's data types, see :manual:`BSON Types </reference/bson-types/>`
230237
in the Server manual.
231238

docs/query-builder.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,13 @@ query builder method to retrieve documents from the
346346
:start-after: begin query whereDate
347347
:end-before: end query whereDate
348348

349+
.. note:: Date Query Result Type
350+
351+
Starting in {+odm-long+} v5.0, ``UTCDateTime`` BSON values in MongoDB
352+
are returned as `Carbon <https://carbon.nesbot.com/docs/>`__ date
353+
classes in query results. The {+odm-short+} applies the default
354+
timezone when performing this conversion.
355+
349356
.. _laravel-query-builder-pattern:
350357

351358
Text Pattern Match Example

0 commit comments

Comments
 (0)