PHP date_default_timezone_set () function
PHP Date / Time Reference Manual
Examples
Set the default time zone:
<?php
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?>
date_default_timezone_set("Asia/Bangkok");
echo date_default_timezone_get();
?>
Running instance »
Definition and Usage
date_default_timezone_set () function sets the script all date / time functions using the default time zone.
grammar
date_default_timezone_set( timezone );
参数 | 描述 |
---|---|
timezone | 必需。规定要使用的时区,比如 "UTC" 或 "Europe/Paris"。合法时区的列表: http://www.php.net/manual/en/timezones.php |
technical details
return value: | If timezone substandard rule returns FALSE, otherwise it returns TRUE. |
---|---|
PHP version: | 5.1+ |
Update log: | Starting from PHP 5.1.2+, the function parameter start verifying timezone. From PHP 5.3+ start throwing E_WARNING rather than E_STRICT. |
PHP Date / Time Reference Manual