PHP Tutorial Set the Date_default_timezone_set function ()
Definition and usage
The Date_default_timezone_set () function sets the default time zone for all date/time functions used in the script.
Grammar
Date_default_timezone_set (TimeZone)
$now = time ();
Date_default_timezone_set (' america/new York ');
Print date (' C ', $now);
Date_default_timezone_set (' Europe/paris ');
Print date (' C ', $now);
?>
Look at one more example.
Date_default_timezone_set (' America/denver ');
$summer = Mktime (12,0,0,7,4,2008);
Print date (' C ', $summer). "N";
Date_default_timezone_set (' America/phoenix ');
Print date (' C ', $summer). "N";
?>
Note: since PHP 5.1.0 (This version of the date time function is rewritten), if the time zone is not a rule, each call to a DateTime function produces an E_notice level error message, and the e_strict level of information is generated if the system setting or the TZ environment variable is used.
Reference table
Table h-10. Others
CET cst6cdt Cuba Egypt
Eire est Est5edt etc/gmt etc/gmt+0
Etc/gmt+1 etc/gmt+10 etc/gmt+11 etc/gmt+12 etc/gmt+2
Etc/gmt+3 etc/gmt+4 etc/gmt+5 etc/gmt+6 etc/gmt+7
Etc/gmt+8 etc/gmt+9 etc/gmt-0 etc/gmt-1 etc/gmt-10
etc/gmt-11 etc/gmt-12 etc/gmt-13 etc/gmt-14 etc/gmt-2
Etc/gmt-3 etc/gmt-4 etc/gmt-5 etc/gmt-6 etc/gmt-7
Etc/gmt-8 etc/gmt-9 etc/gmt0 Etc/greenwich etc/uct
Etc/universal ETC/UTC Etc/zulu Factory GB
gb-eire GMT gmt+0 gmt-0 gmt0
Greenwich HONGKONG HST Iceland Iran
Israel Jamaica Japan Kwajalein Libya
Met MST MST7MDT Navajo NZ
Nz-chat Poland Portugal PRC PS Tutorial T8PDT
ROC rok Singapore Turkey UCT
Universal UTC W-su Wet Zulu
http://www.bkjia.com/PHPjc/632296.html www.bkjia.com true http://www.bkjia.com/PHPjc/632296.html techarticle The PHP tutorial sets the Date_default_timezone_set () definition and usage of the Date_default_timezone_set () function to set the default time zone for all date/time functions used in the script. Grammar ...