Mst time zone in php

Hi,

I'm trying to compute current time for mountain standard time with
daylight savings (MDT);and without DST (MST), eg: Phoenix, AZ.

If I use the PHP timezone "US/Mountain", it returns MDT correctly.
What is the PHP time zone for MST?

Similarly, are there PHP time zones for Pacific, Central and Eastern
time zones without Daylight Savings? The PHP time zones US/Pacific, US/
Central and US/Eastern all show time with Daylight Savings.

Jul 3 '07 #1

On Jul 3, 6:48 am, wrote:

Hi,

I'm trying to compute current time for mountain standard time with
daylight savings (MDT);and without DST (MST), eg: Phoenix, AZ.

If I use the PHP timezone "US/Mountain", it returns MDT correctly.
What is the PHP time zone for MST?

Similarly, are there PHP time zones for Pacific, Central and Eastern
time zones without Daylight Savings? The PHP time zones US/Pacific, US/
Central and US/Eastern all show time with Daylight Savings.

There is a complete list of timezones supported by PHP in the PHP
manual.

<http://www.php.net/manual/en/timezones.php>

Jul 3 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Change language:

Submit a Pull Request Report a Bug

Table of Contents

  • Africa
  • America
  • Antarctica
  • Arctic
  • Asia
  • Atlantic
  • Australia
  • Europe
  • Indian
  • Pacific
  • Others

Here you'll find the complete list of timezones supported by PHP, which are meant to be used with e.g. date_default_timezone_set().

Caution

The behavior of timezones not listed here is undefined.

Note: The latest version of the timezone database can be installed via PECL's » timezonedb.

Note: This list is based upon the timezone database version 2022.2.

+add a note

User Contributed Notes

There are no user contributed notes for this page.

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.

asked Feb 14, 2011 at 5:48

6

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

answered Feb 14, 2011 at 6:01

JohnJohn

9,40025 gold badges89 silver badges136 bronze badges

6

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

answered Sep 10, 2012 at 20:31

jgrowljgrowl

2,0172 gold badges17 silver badges23 bronze badges

1

This will automatically get you a list of American timezones:

if (defined('DateTimeZone::AMERICA')) {
    // PHP 5.3+
    $timezoneIdentifiers = timezone_identifiers_list(DateTimeZone::AMERICA);
} else {
    // PHP 5.2
    $timezoneIdentifiers = timezone_identifiers_list();
    $timezoneIdentifiers = array_filter($timezoneIdentifiers, create_function('$tz', 'return preg_match("/^America\//", $tz);'));
}

Note that this will include South American, Canadian etc timezones as well though. You could play around with DateTimeZone::PER_COUNTRY as a filter to timezone_identifiers_list for PHP 5.3 and see if that gets you want you want, or filter the complete list for US/. The best choice is probably to handpick the timezones though.

answered Feb 14, 2011 at 5:55

decezedeceze

496k81 gold badges717 silver badges864 bronze badges

1

Brute-force way to get ALL timezones per country using PHP's GEOIP. The code is not intended to look nice. You should call this only once and store the result somewhere.

$timezones = array();

foreach (range('A', 'Z') as $i) {
    foreach (range('A', 'Z') as $j) {
        $country = $i . $j;

        foreach (range('A', 'Z') as $k) {
            foreach (range('A', 'Z') as $l) {
                $region = $k . $l;

                if ($timezone = geoip_time_zone_by_country_and_region($country, $region)) {
                    $timezones[$country][$timezone] = true;
                }
            }
        }

        foreach (range(0, 99) as $m) {
            if ($timezone = geoip_time_zone_by_country_and_region($country, sprintf('%02d', $m))) {
                $timezones[$country][$timezone] = true;
            }
        }
    }
}

var_dump($timezones);

answered Feb 13, 2014 at 8:50

maryomaryo

6,3893 gold badges15 silver badges9 bronze badges

Not the answer you're looking for? Browse other questions tagged php timezone or ask your own question.

Where is MST time zone?

The MST time zone is the least populated time zone in the USA. It spans from northern Canada to Mexico near the equator. In North America, Mountain Standard Time shares a border with Central Standard Time (CST) in the east and with Pacific Standard Time (PST) in the west.

What is PHP time zone?

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.

Is MST and MDT the same?

MDT or MST? Mountain Daylight Time (MDT) is a North American time zone in use from the second Sunday in March to the first Sunday in November during Daylight Saving Time (DST). Mountain Standard Time (MST) is used during the remainder of the year.

Is it MDT or MST right now?

MST time now (MST / MDT). Current Mountain Time now in USA and Canada.