Php sets the Beijing time function date_default_timezone_set (). In the php Tutorial, set the definition and usage of the Beijing time function date_default_timezone_set () to the default time zone of all date and time functions in the script. Syntax php Tutorial setting Beijing time function date_default_timezone_set ()
Definition and usage
The date_default_timezone_set () function is used to set the default time zone of all date/time functions in the script.
Syntax
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 );
?>
Let's look at another example.
Date_default_timezone_set ('America/denver ');
$ Summer = mktime );
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 DATETIME function has been rewritten), if the time zone does not comply with the rules, every call to the DATETIME function will generate an e_notice-level error message, if you use system settings or tz environment variables, information at the e_strict level will also be generated.
Reference Table
Table H-10. others
Cet cst6cdt cuba eet egypt
Eire est est5edt 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/
Etc/GMT-3 etc/GMT-4 etc/GMT-5 etc/GMT-6 etc/GMT-7 etc/
Etc/GMT-8 etc/gmt-9 etc/gmt0 etc/greenwich etc/uct
Etc/universal etc/utc etc/zulu factory gb
Gb-eire 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 pstutorial t8pdt
Roc rok singapore turkey uct
Universal utc w-su wet zulu
Define () and use date_default_timezone_set () to set the default time zone of all date/time functions in the script. Syntax...