1
0
mirror of https://github.com/php/php-src.git synced 2026-04-24 00:18:23 +02:00
Files
Niels Dossche ee26417b58 Fix timezone offset with seconds losing precision
There are two issues:
1. The 'e' formatter doesn't output the seconds of the timezone even if
   it has seconds.
2. var_dump(), (array) cast, serialization, ... don't include the
   timezone second offset in the output. This means that, for example,
   serializing and then unserializing a date object loses the seconds of
   the timezone. This can be observed by comparing the output of
   getTimezone() for `$dt` vs the unserialized object in the provided test.

Closes GH-20764.
2026-02-05 18:38:54 +01:00

21 lines
431 B
PHP

--TEST--
Bug #81565 (date parsing fails when provided with timezones including seconds)
--FILE--
<?php
var_export(
\DateTime::createFromFormat(
'Y-m-d H:i:sO',
'0021-08-21 00:00:00+00:49:56'
)
);
echo "\n", (new DatetimeZone('+01:45:30'))->getName();
?>
--EXPECT--
\DateTime::__set_state(array(
'date' => '0021-08-21 00:00:00.000000',
'timezone_type' => 1,
'timezone' => '+00:49:56',
))
+01:45:30