Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions en/appendices/4-0-migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,12 @@ Miscellaneous
New Features
============

Database
--------

* If your database's timezone does not match PHP timezone then you can use the
``DateTime::setTimezone()`` method. See :ref:`datetime-type` for details.

Filesystem
----------

Expand Down
24 changes: 20 additions & 4 deletions en/orm/database-basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -350,10 +350,7 @@ date
type is :php:class:`Cake\\I18n\\Date` which extends the native ``DateTime``
class.
datetime
Maps to a timezone naive ``DATETIME`` column type. In PostgreSQL, and SQL Server
this turns into a ``TIMESTAMP`` type. The default return value of this column
type is :php:class:`Cake\\I18n\\Time` which extends the built-in
``DateTime`` class and `Chronos <https://github.com/cakephp/chronos>`_.
See :ref:`datetime-type`.
timestamp
Maps to the ``TIMESTAMP`` type.
time
Expand All @@ -372,6 +369,25 @@ automatically convert input parameters from ``DateTime`` instances into a
timestamp or formatted datestrings. Likewise, 'binary' columns will accept file
handles, and generate file handles when reading data.

.. _datetime-type:

DateTime Type
-------------

.. php:class:: Type\DateTimeType

Maps to a timezone naive ``DATETIME`` column type. In PostgreSQL, and SQL Server

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naive or native? :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had just moved the sentence. Fixed in new PR.

this turns into a ``TIMESTAMP`` type. The default return value of this column
type is :php:class:`Cake\\I18n\\FrozenTime` which extends the built-in
``DateTimeImmutable`` class and `Chronos <https://github.com/cakephp/chronos>`_.

.. php:method:: setTimezone(string|\DateTimeZone|null $timezone)

If your database server's timezone does not match your application's PHP timezone
then you can use this method to specify your database's timezone. This timezone
will then used when converting PHP objects to database's datetime string and
vice versa.

.. _adding-custom-database-types:

Adding Custom Types
Expand Down