PHP date_default_timezone_set()Functions
PHP Date/Time Reference Manual
Examples
Set the default timezone:
date_default_timezone_set("Asia/Shanghai");
echo date_default_timezone_get();
Run Example »
Definition and Usage
The date_default_timezone_set() function sets the default timezone used by all date/time functions in the script.
Syntax
date_default_timezone_set(timezone);
| Parameters | Description |
|---|---|
| timezone | Required. Specifies the timezone to use, such as "UTC" or "Europe/Paris". List of valid timezones: http://www.php.net/manual/en/timezones.php |
Technical Details
| Return value: | Returns FALSE iftimezoneis invalid, otherwise returns TRUE. |
|---|---|
| PHP Version: | 5.1+ |
| Changelog: | As of PHP 5.1.2+, this function began validating thetimezoneparameter. As of PHP 5.3+, throws E_WARNING instead of E_STRICT. |
PHP Date/Time Reference Manual Other Extensions