php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79316 DateTime initiated with EST time zone behaving incorrectly
Submitted: 2020-02-28 10:57 UTC Modified: 2020-02-28 11:37 UTC
From: niklas dot lampen at supermetrics dot com Assigned: cmb (profile)
Status: Not a bug Package: Date/time related
PHP Version: 7.4.3 OS:
Private report: No CVE-ID: None
 [2020-02-28 10:57 UTC] niklas dot lampen at supermetrics dot com
Description:
------------
When initiating DateTime with time zone string 'EST', the hours are wrong, while the time zone correction is correct.

When using DateTimeZone to set time zone, it works as expected. With other time zones the shorthand works correctly.

Test script:
---------------
echo (new DateTime('EST'))->format('c');
echo PHP_EOL;
echo (new DateTime('now', new DateTimeZone('EST')))->format('c');

echo PHP_EOL . PHP_EOL;

echo (new DateTime('UTC'))->format('c');
echo PHP_EOL;
echo (new DateTime('now', new DateTimeZone('UTC')))->format('c');

echo PHP_EOL . PHP_EOL;

echo (new DateTime('America/New_York'))->format('c');
echo PHP_EOL;
echo (new DateTime('now', new DateTimeZone('America/New_York')))->format('c');

Expected result:
----------------
2020-02-28T05:46:26-05:00
2020-02-28T05:46:26-05:00

2020-02-28T10:46:26+00:00
2020-02-28T10:46:26+00:00

2020-02-28T05:46:26-05:00
2020-02-28T05:46:26-05:00

Actual result:
--------------
2020-02-28T11:46:26-05:00
2020-02-28T05:46:26-05:00

2020-02-28T10:46:26+00:00
2020-02-28T10:46:26+00:00

2020-02-28T05:46:26-05:00
2020-02-28T05:46:26-05:00

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-28 11:37 UTC] cmb@php.net
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2020-02-28 11:37 UTC] cmb@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Form <https://www.php.net/manual/en/timezones.others.php>:

| Please do not use any of the timezones listed here (besides
| UTC), they only exist for backward compatible reasons, and may
| expose erroneous behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 15:01:31 2024 UTC