File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -216,8 +216,8 @@ type, to the Laravel ``datetime`` type.
216
216
To learn more, see `Attribute Casting <https://laravel.com/docs/{+laravel-docs-version+}/eloquent-mutators#attribute-casting>`__
217
217
in the Laravel documentation.
218
218
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
221
221
in this field. The following example shows a Laravel query that uses the
222
222
casting helper on the model to query for planets with a ``discovery_dt`` of
223
223
less than three years ago:
@@ -226,6 +226,13 @@ less than three years ago:
226
226
227
227
Planet::where( 'discovery_dt', '>', new DateTime('-3 years'))->get();
228
228
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
+
229
236
To learn more about MongoDB's data types, see :manual:`BSON Types </reference/bson-types/>`
230
237
in the Server manual.
231
238
Original file line number Diff line number Diff line change @@ -346,6 +346,13 @@ query builder method to retrieve documents from the
346
346
:start-after: begin query whereDate
347
347
:end-before: end query whereDate
348
348
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
+
349
356
.. _laravel-query-builder-pattern:
350
357
351
358
Text Pattern Match Example
You can’t perform that action at this time.
0 commit comments