Home >Backend Development >PHP Tutorial >PHP sets Beijing time function date_default_timezone_set()_PHP tutorial

PHP sets Beijing time function date_default_timezone_set()_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:54:471410browse

php tutorial to set Beijing time function date_default_timezone_set()
Definition and Usage
The date_default_timezone_set() function sets the default time zone used for all date/time functions in scripts.

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 another 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 (the date and time function has been rewritten in this version), if the time zone is illegal, each call to the date and time function will generate an e_notice level error message. If you use the system setting or The tz environment variable also generates e_strict level information.


Reference table

Form h-10. others

cet cst6cdt cuba eet 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

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/632296.htmlTechArticlephp tutorial to set Beijing time function date_default_timezone_set() Definition and usage date_default_timezone_set() function sets all dates used in the script/ The default time zone for time functions. Grammar...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn