|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-07-04 08:13 UTC] nospam at tils dot org
Description:
------------
If you set a timezone on a DateTime object and you output "e" and "T" values, different Timezones will be returned. I have a german system here and PHP 7.2 seems to always output the system timezone in "T", but output the manually assigned timezone in "e".
In PHP 5.6 the output of the test script is: "12:15:03 UTC UTC"
In PHP 7.2.7 the output is: "12:15:03 UTC CEST"
Test script:
---------------
<?php
$date = new Datetime('2018-05-01 12:15:03');
$date->setTimeZone(new DateTimeZone('UTC'));
echo $date->format('H:i:s e T');
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 20:00:01 2025 UTC |
I have one machine: OpenSuSE Tumbleweed with 20180626 php 5.6.31 The other machine is a docker container with Ubuntu 16.04.4 LTS and php 7.2.7 The output of ini_get('date.timezone') on the (working) 5.6 installation is "UTC", on the (broken) 7.2 installation is "". If I add an ini_set('date.timezone', 'UTC') the 7.2 also shows the same problem. I start the very same script inside the docker container by php-cli and outside in the host system. So yes, they are the same.I changed my date time to January 3 8:00 am on my computer. Ran this $d2 = new DateTime(date("Y-m-d"), new DateTimeZone('UTC')); echo $d2->format('Y-m-d H:i:s'); And I get this 2023-01-03 00:00:00 Change my computer Date to January 3 8:00 pm on my computer. Ran the same script. I get this. 2023-01-04 00:00:00When running this script. $d2 = new DateTime(date("Y-m-d"), new DateTimeZone('America/Phoenix')); echo $d2->format('Y-m-d H:i:s'); I get the same result.