How to set the time zone in php: You can use the function ini_set('date.timezone','Asia/Shanghai') to set the time zone. You can also use the function date_default_timezone_set('Asia/Shanghai') to set it.
Use the function date_default_timezone_set('Asia/Shanghai'); in the program code of PHP 5 or above to set the time zone, you can also add # at the beginning of the file ##
ini_set('date.timezone','Asia/Shanghai'); // 'Asia/Shanghai' 为上海时区
php graphic tutorial)
Code example:<?php function_exists(date_default_timezone_set);//在这他总是返回1,这函数是判断这里面的字符是不是一个定义了的函数名 date_default_timezone_set("Etc/GMT");//这是格林威治标准时间,得到的时间和默认时区是一样的 date_default_timezone_set("Etc/GMT+8");//这里比林威治标准时间慢8小时 date_default_timezone_set("Etc/GMT-8");//这里比林威治标准时间快8小时 date_default_timezone_set('PRC'); //设置中国时区 ?>
php video tutorial)
Find the configuration "data.timezone" in php.ini, remove the ; sign in front of it, and then set it manually data.timezone = “Asia/Shanghai”; That’s it. Description of some commonly used time zone identifiers:The above is the detailed content of How to set time zone in php. For more information, please follow other related articles on the PHP Chinese website!