Skip to content

Commit 61d79c6

Browse files
committed
Merge branch '3.8.x' into 4.0.x
* 3.8.x: Connection::setNestTransactionsWithSavepoints() should not break lazy connection (#6362) [Docs] Update docs regarding "datetimetz" type (#6014)
2 parents 7fb00fd + b05e48a commit 61d79c6

File tree

3 files changed

+38
-18
lines changed

3 files changed

+38
-18
lines changed

docs/en/reference/known-vendor-issues.rst

+19-9
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,20 @@ MySQL
7070
DateTimeTz
7171
~~~~~~~~~~
7272

73-
MySQL does not support saving timezones or offsets. The DateTimeTz
74-
type therefore behaves like the DateTime type.
73+
Prior to version 8.0.19, MySQL does not support saving timezones or offsets. The DateTimeTz type therefore
74+
behaves like the DateTime type on previous versions.
75+
Starting from version `8.0.19 and later <https://dev.mysql.com/doc/refman/8.0/en/date-and-time-literals.html#date-and-time-string-numeric-literals>`_,
76+
timezone offsets are supported. MySQL converts the time zone offset to UTC for storage, and back from UTC to the current
77+
(SYSTEM, SESSION, etc) time zone for retrieval.
78+
79+
MariaDB
80+
-------
81+
82+
DateTimeTz
83+
~~~~~~~~~~
84+
85+
MariaDB does not support saving timezone offsets. The DateTimeTz type therefore behaves like the DateTime
86+
type.
7587

7688
Sqlite
7789
------
@@ -86,7 +98,7 @@ breaks the SERIALIZABLE transaction isolation property that SQLite supposedly
8698
has.
8799

88100
DateTime
89-
~~~~~~~~~~
101+
~~~~~~~~
90102

91103
Unlike most database management systems, Sqlite does not convert supplied
92104
datetime strings to an internal storage format before storage. Instead, Sqlite
@@ -104,8 +116,8 @@ when trying to convert database values to ``\DateTime`` objects using
104116
DateTimeTz
105117
~~~~~~~~~~
106118

107-
Sqlite does not support saving timezones or offsets. The DateTimeTz
108-
type therefore behaves like the DateTime type.
119+
Sqlite supports saving timezone offsets, but this feature is not yet implemented in DBAL.
120+
The DateTimeTz type therefore behaves like the DateTime type.
109121

110122
Reverse engineering primary key order
111123
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -121,10 +133,8 @@ IBM DB2
121133
DateTimeTz
122134
~~~~~~~~~~
123135

124-
DB2 does not save the actual Timezone Name but UTC-Offsets. The
125-
difference is subtle but can be potentially very nasty. Derick
126-
Rethans explains it very well
127-
`in a blog post of his <http://derickrethans.nl/storing-date-time-in-database.html>`_.
136+
DB2 does not support saving timezone offsets. The DateTimeTz type therefore behaves like the DateTime
137+
type.
128138

129139
Oracle
130140
------

docs/en/reference/types.rst

+9
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,15 @@ information, you should consider using this type.
311311
Values retrieved from the database are always converted to PHP's ``\DateTime`` object
312312
or ``null`` if no data is present.
313313

314+
.. note::
315+
316+
This type is not supported by all the vendor platforms or by all of their versions. Depending on
317+
these variants, the databases that support this type may return the persisted date and time in a
318+
different timezone than the one used during the ``INSERT`` or the ``UPDATE`` operation. This means
319+
that if you persist a value like `1986-22-03 19:45:30-03:00`, you could have `1986-22-03 22:45:30-00:00`
320+
as the result of a ``SELECT`` operation for that record. In these cases, the timezone offset present
321+
in the result is usually UTC or the one configured as default in the database server.
322+
314323
.. warning::
315324

316325
Passing instances of ``DateTimeImmutable`` to this type is deprecated since 3.7. Use

src/Types/DateTimeTzType.php

+10-9
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,19 @@
1010
use Doctrine\DBAL\Types\Exception\InvalidType;
1111

1212
/**
13-
* DateTime type saving additional timezone information.
13+
* DateTime type accepting additional information about timezone offsets.
1414
*
1515
* Caution: Databases are not necessarily experts at storing timezone related
16-
* data of dates. First, of all the supported vendors only PostgreSQL and Oracle
17-
* support storing Timezone data. But those two don't save the actual timezone
18-
* attached to a DateTime instance (for example "Europe/Berlin" or "America/Montreal")
19-
* but the current offset of them related to UTC. That means depending on daylight saving times
20-
* or not you may get different offsets.
16+
* data of dates. First, of not all the supported vendors support storing Timezone data, and some of
17+
* them only use the offset to calculate the timestamp in its default timezone (usually UTC) and persist
18+
* the value without the offset information. They even don't save the actual timezone names attached
19+
* to a DateTime instance (for example "Europe/Berlin" or "America/Montreal") but the current offset
20+
* of them related to UTC. That means, depending on daylight saving times or not, you may get different
21+
* offsets.
2122
*
22-
* This datatype makes only sense to use, if your application works with an offset, not
23-
* with an actual timezone that uses transitions. Otherwise your DateTime instance
24-
* attached with a timezone such as Europe/Berlin gets saved into the database with
23+
* This datatype makes only sense to use, if your application only needs to accept the timezone offset,
24+
* not the actual timezone that uses transitions. Otherwise your DateTime instance
25+
* attached with a timezone such as "Europe/Berlin" gets saved into the database with
2526
* the offset and re-created from persistence with only the offset, not the original timezone
2627
* attached.
2728
*/

0 commit comments

Comments
 (0)