A related question about the PHPdate () function

Source: Internet
Author: User
Tags echo date
One question about the PHPdate () function today, when I checked the php manual, I found that the date function can directly pass the parameter Z. The php Manual explains that date (Z) is the time difference offset in seconds. The time zone offset to the west of UTC is always negative, and the time zone offset to the east of UTC is always positive. But I will execute the following code: PHPcode & lt ;? Phpechodate (Y-m-dH: I: s, time (); output a question about the PHPdate () function
When I checked the php Manual today, I found that the date function can directly transmit the parameter Z. The php Manual explains that date ('Z') is the time difference offset in seconds. The time zone offset to the west of UTC is always negative, and the time zone offset to the east of UTC is always positive. But I will execute the following code:

PHP code
  

  


In principle, it is 8 hours behind each other. why is the output of 8 in date ('Z')/3600 0?

------ Solution --------------------
The output is 8.
If your time zone is not modified, it should be 0

Echo date ('yz')/3600;
Echo gmdate ('yz')/3600;
If the two outputs are the same, your time is Greenwich Mean Time.
------ Solution --------------------
Because you have not set the local time zone, if you set date. timezone in php. ini or use date_default_timezone_set ()
Specifies the local time zone and the result is 8.
------ Solution --------------------
You use the default green time. Therefore, the echo date ('Z') offset returns 0.

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.