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.
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
date_default_timezone_set — Sets the default timezone used by all date/time functions in a script
Description
date_default_timezone_set(string $timezoneId): bool
Instead of using this function to set the default timezone in your script, you can also use the INI setting date.timezone to set the default timezone.
Parameters
timezoneIdThe timezone identifier, like UTC, Africa/Lagos, Asia/Hong_Kong, or Europe/Lisbon. The list of valid identifiers is available in the List of Supported Timezones.
Return Values
This function returns false if the timezoneId isn't valid, or true otherwise.
Examples
Example #1 Getting the default timezone
<?php
date_default_timezone_set('America/Los_Angeles');$script_tz = date_default_timezone_get();
if (
strcmp($script_tz, ini_get('date.timezone'))){echo 'Script timezone differs from ini-set timezone.';
} else {
echo 'Script timezone and ini-set timezone match.';
}
?>
See Also
- date_default_timezone_get() - Gets the default timezone used by all date/time functions in a script
- List of Supported Timezones
Pierre Gourlaouen ¶
10 years ago
A simple method for conversation between two time zone.
<?php
$date = new DateTime("2012-07-05 16:43:21", new DateTimeZone('Europe/Paris'));
date_default_timezone_set('America/New_York');
echo
date("Y-m-d h:iA", $date->format('U')); // 2012-07-05 10:43AM?>
Asked 8 years, 10 months ago
Viewed 12k times
What is default timezone in php? I checked it in the php.ini which shows the following with the timezone is left blank:
[Date] ; Defines the default timezone used by the date functions ;date.timezone = ;date.default_latitude = 31.7667 ;date.default_longitude = 35.2333 ;date.sunrise_zenith = 90.583333 ;date.sunset_zenith = 90.583333Then I want to know which timezone is used by default while manipulating times in PHP if I don't set it explicitly by using date_deafult_timezone_set() or any other means ?
asked Nov 10, 2013 at 15:27
Parveez AhmedParveez Ahmed
1,3094 gold badges15 silver badges28 bronze badges
8
PHP 7 Answer
Modern versions of PHP (>= 5.4.0) use the following steps until a default timezone is found:
Reading the timezone set using the date_default_timezone_set() function (if any)
Reading the value of the date.timezone ini option (if set)
If none of the above succeed, the default timezone will be UTC.
The TZ environment variable is no longer used.
Source: //www.php.net/manual/en/function.date-default-timezone-get.php
answered Mar 10, 2020 at 23:44
Josh BernfeldJosh Bernfeld
3,9662 gold badges30 silver badges35 bronze badges
1
A simple code you have to write for the default timezone. which is:
date_default_timezone_get()Now how to use:
You have to pass the timezone in this function like we want to set India timezone as default see:
date_default_timezone_set("Asia/Kolkata");Now, whenever you would use date(), automatically return India timezone.
I would refer if you want a example: how to convert default date timezone in php
answered Feb 10, 2015 at 14:49
;date.timezone = ; This is diasable text This is working text
Get it? with this ; On some ini files you can disable some scripts/codes. You can set your time zone in php like: date_default_timezone_set('Europe/London'); And other like Europe/Amsterdam... Read more on php default timezone
answered Nov 10, 2013 at 15:41