PHP date_default_timezone_set() Function
Example
Set Default Time Zone:
<?php date_default_timezone_set("Asia/Shanghai"); echo date_default_timezone_get(); ?>
Definition and Usage
The date_default_timezone_set() function sets the default time zone for all date/time functions used in the script.
Syntax
date_default_timezone_set(timezone);
Parameters | Description |
---|---|
timezone |
Required. Specify the time zone to be used, such as "UTC" or "Europe/Paris". List of valid time zones: http://www.php.net/manual/en/timezones.php |
Technical Details
Return Value: | If timezone If invalid, it returns FALSE; otherwise, it returns TRUE. |
---|---|
PHP Version: | 5.1+ |
Update Log: |
Starting from PHP 5.1.2+, this function begins to validate timezone Parameters. Starting from PHP 5.3+, it throws E_WARNING instead of E_STRICT. |