Home  >  Article  >  Backend Development  >  How to use php to output time format_PHP tutorial

How to use php to output time format_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:12:14803browse

Copy code The code is as follows:

date_default_timezone_set("ETC/GMT-8");
$ tm=time();
echo date("Y-m-d h:i a",$tm);
echo "

";
echo date(" Y year m month d day",$tm);
?>

PHP default time zone UTC time zone, and Beijing is located in the east eighth district of this time zone, 8 times ahead of UTC time zone hours, so the current time obtained using the time() function in PHP is always 8 hours different.

can be configured in the following two ways:
1. Modify the value of date.timezone in the php.ini file
2. Use special Function to set time zone, date_default_timezone_set("ETC/GMT-8");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/313671.htmlTechArticleCopy the code as follows: ? date_default_timezone_set("ETC/GMT-8"); $tm=time(); echo date("Y-m-d h:i a",$tm); echo "br/br/"; echo date("Y year m month d day",$tm); ? PHP default time zone UTC time...
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