From b69f06047d646492b6a4de7349a34fdcd7c233a9 Mon Sep 17 00:00:00 2001 From: ADmad Date: Mon, 25 Feb 2019 13:31:26 +0530 Subject: [PATCH] Add section for DatetimeType. Refs cakephp/cakephp#13005 --- en/appendices/4-0-migration-guide.rst | 6 ++++++ en/orm/database-basics.rst | 24 ++++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/en/appendices/4-0-migration-guide.rst b/en/appendices/4-0-migration-guide.rst index 79a12301f2..a59d49ec92 100644 --- a/en/appendices/4-0-migration-guide.rst +++ b/en/appendices/4-0-migration-guide.rst @@ -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 ---------- diff --git a/en/orm/database-basics.rst b/en/orm/database-basics.rst index 30e690243c..248110c8de 100644 --- a/en/orm/database-basics.rst +++ b/en/orm/database-basics.rst @@ -345,10 +345,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 `_. + See :ref:`datetime-type`. timestamp Maps to the ``TIMESTAMP`` type. time @@ -376,6 +373,25 @@ handles, and generate file handles when reading data. .. versionchanged:: 3.6.0 The ``binaryuuid`` type was added. +.. _datetime-type: + +DateTime Type +------------- + +.. php:class:: Type\DateTimeType + +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\\FrozenTime` which extends the built-in +``DateTimeImmutable`` class and `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