php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76576 DateTime formats different Timezones with 'e' and 'T' format codes
Submitted: 2018-07-04 08:13 UTC Modified: 2023-01-04 09:26 UTC
From: nospam at tils dot org Assigned: heiglandreas (profile)
Status: Closed Package: Date/time related
PHP Version: 7.2.7 OS: Ubuntu
Private report: No CVE-ID: None
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 - 12 = ?
Subscribe to this entry?

 
 [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');


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-07-04 08:51 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2018-07-04 08:51 UTC] requinix@php.net
I can't figure out how to reproduce this. Are you running that exact script? Unchanged? Are you doing anything else with timezones? Do you have the date.timezone setting something other than UTC?
 [2018-07-04 08:59 UTC] nospam at tils dot org
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.
 [2018-07-04 09:09 UTC] requinix@php.net
-Status: Feedback +Status: Open
 [2018-07-04 09:09 UTC] requinix@php.net
Well, all I can think of is that your timezone database is messed up and somehow has a "UTC" timezone mapped to CEST.
 [2018-07-04 09:59 UTC] nospam at tils dot org
Regarding your assumption I added the output of DateTime::listAbbrevations().

I didnt find a method to add a file here, so here you can find it:

https://cloud.tils.org/index.php/s/9DSZSL8arndXG7b
 [2021-04-06 18:39 UTC] derick@php.net
-Status: Open +Status: Feedback
 [2021-04-06 18:39 UTC] derick@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

I can't reproduce this.
 [2021-04-18 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2023-01-03 22:00 UTC] aaron dot hammond at loanpro dot io
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:00
 [2023-01-03 22:05 UTC] aaron dot hammond at loanpro dot io
When 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.
 [2023-01-04 09:26 UTC] heiglandreas@php.net
-Status: No Feedback +Status: Closed -Assigned To: +Assigned To: heiglandreas
 [2023-01-04 09:26 UTC] heiglandreas@php.net
Are we talking about two different things here? 

As the initial issue was about something completely different.

The original issue seems not to be reproducible in a controlled environment.

See https://3v4l.org/aP36J

Please create a separate bug-report for the issue from the last comments.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 07 03:01:26 2024 UTC