Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List of US Time Zones for PHP to use? [closed]

Tags:

timezone

php

Is there just a list of time zones for the united states I can use with php? Im using the timezone names from php such as America/Anchorage, php lists time zones here:

http://us.php.net/manual/en/timezones.others.php

I want to display them in a drop down for the user to select but I only need the ones for the US, I dont want to show a bunch that are outside the US.

like image 385
John Avatar asked Feb 14 '11 05:02

John


People also ask

What timezone does PHP use?

The default timezone for PHP is UTC regardless of your server's timezone. This is the timezone used by all PHP date/time functions in your scripts.

Does USA have 7 time zones?

The United States is divided into six time zones: Hawaii-Aleutian time, Alaska time, Pacific time, Mountain time, Central time and Eastern time.

How many time zones the US have?

There are six designated US time zones; and there are four time zones in the contiguous USA. The Aleutian Islands, a spur of Alaska, and the Hawaiian Islands in the Pacific Ocean are 3750 km (2330 mi) apart but lie at similar longitudes.


2 Answers

Here is a list I found:

Eastern Time    America/New_York Central Time    America/Chicago Mountain Time   America/Denver Mountain Time (no DST) America/Phoenix Pacific Time    America/Los_Angeles Alaska Time America/Anchorage Hawaii-Aleutian America/Adak Hawaii-Aleutian Time (no DST) Pacific/Honolulu 
like image 94
John Avatar answered Oct 14 '22 11:10

John


As deceze said, you can use the PER_COUNTRY flag.

$timezone_identifiers = DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US'); foreach($timezone_identifiers as $timezone_identifier) {   echo "$timezone_identifier\n"; } 

Output:

America/Adak America/Anchorage America/Boise America/Chicago America/Denver America/Detroit America/Indiana/Indianapolis America/Indiana/Knox America/Indiana/Marengo America/Indiana/Petersburg America/Indiana/Tell_City America/Indiana/Vevay America/Indiana/Vincennes America/Indiana/Winamac America/Juneau America/Kentucky/Louisville America/Kentucky/Monticello America/Los_Angeles America/Menominee America/Metlakatla America/New_York America/Nome America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem America/Phoenix America/Shiprock America/Sitka America/Yakutat Pacific/Honolulu 
like image 29
jgrowl Avatar answered Oct 14 '22 11:10

jgrowl