What timezone does php use?

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.

(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

timezoneId

The 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_tzini_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.583333

Then 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:

  1. Reading the timezone set using the date_default_timezone_set() function (if any)

  2. Reading the value of the date.timezone ini option (if set)

  3. If none of the above succeed, the default timezone will be UTC.

The TZ environment variable is no longer used.

Source: https://www.php.net/manual/en/function.date-default-timezone-get.php

answered Mar 10, 2020 at 23:44

What timezone does php use?

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

What timezone does php use?

;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

What timezone does php use?

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

Where is PHP timezone set?

8 Answers.
Go to your phpinfo() page and search for Loaded Configuration File and open the php. ini file mentioned under that section..
Change the default timezone settings by adding your new timezone by modifying this line: date. timezone=Asia/Kolkata ..
Save the php. ... .
Restart the Apache server..

How does PHP manage different time zones?

The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.

What is default timezone?

The defaultTimeZone time zone is used by the app for date and time operations. You can set it to cause the app to run as if it were in a different time zone. Setting the defaultTimeZone property clears any value that was previously set.

How do I find my server time zone?

The currently configured timezone is set in the /etc/timezone file. To view your current timezone you can cat the file's contents. Another method is to use the date command. By giving it the argument +%Z , you can output your system's current time zone name.