php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #81194 Get Timezone abbreviation
Submitted: 2021-06-23 07:58 UTC Modified: 2021-06-23 09:11 UTC
From: syl dot fabre at gmail dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: syl dot fabre at gmail dot com
New email:
PHP Version: OS:

 

 [2021-06-23 07:58 UTC] syl dot fabre at gmail dot com
Description:
------------
PHP uses the tz database for timezone with names like America/New_York.

But most people in the US use abbreviated names like EST (for instance https://www.juneteenthny.com/schedule) 

This abbreviated name can be found with (new \DateTime('now', 'America/New_York'))->format('T') as explained in this comment: https://www.php.net/manual/en/function.timezone-abbreviations-list.php#97472

I would expect to get this abbreviation from a public method of \DateTimeZone with something like this:
$tz = new \DateTimeZone('America/New_York');
$tz->getAbbreviation();



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-23 08:28 UTC] derick@php.net
-Status: Open +Status: Not a bug
 [2021-06-23 08:28 UTC] derick@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

The abbreviation depends on the date, for 
example whether Daylight Saving Time is 
in effect (EDT vs EST), and also on 
historical data.

Abbreviations are not uniquely 
identifying a specific timezone either 
(PST can also be Pakistan Standard Time). 

Because these abbreviations are strictly 
display only marks (like am/pm), if would 
not be appropriate to have a specific 
method for this, and certainly not 
straight on DateTimezone.
 [2021-06-23 09:11 UTC] syl dot fabre at gmail dot com
This was not a bug report but a feature request :)

Thank you for the explanation about daylight saving.
I understand now why the abbreviation comes from \DateTime::format() and cannot come from the \DateTimeZone itself.

have a nice day
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Feb 05 20:01:30 2025 UTC