How to use php to output time format _ PHP Tutorial

Source: Internet
Author: User
How to use the php output time format. Copy the code as follows :? Date_default_timezone_set (ETCGMT-8); $ tmtime (); echodate (Y-m-dh: ia, $ tm); echobrbr; echodate (Y-m-D, $ tm );? When the default time zone of PHP is UTC 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-m-D", $ tm );
?>


The default time zone of PHP is UTC, while Beijing is located in the GMT + 8, which is eight hours ahead of the UTC time zone. therefore, time () is used in PHP () the current time obtained by the function is always 8 hours different.

You can configure it in either of the following ways:
1. modify the value of date. timezone in the php. ini file
2. use a function that specifically sets the time zone, date_default_timezone_set ("ETC/GMT-8 ");

The http://www.bkjia.com/PHPjc/313671.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/313671.htmlTechArticle code is as follows :? Date_default_timezone_set ("ETC/GMT-8"); $ tm = time (); echo date ("Y-m-d h: I a", $ tm ); echo "br/"; echo date ("Y, m, d", $ tm );? PHP default time zone UTC...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.