A related question about the phpdate () function

Source: Internet
Author: User
Tags echo date
A question about the phpdate () function
Today, when looking at the PHP manual, we found that the date function can be directly passed the parameter z,php the manual explains: date (' Z ') is the number of seconds of the offset of the time difference. The time zone offset in the west of UTC is always negative, and the time zone offset to the east of UTC is always positive. But I execute the following code:

PHP Code
  
  
  
  


According to reason is the difference of 8 hours, date (' Z ')/3600 should output 8 why the output is 0?

------Solution--------------------
Output is 8
If your time zone doesn't change, then it should be 0.

echo Date (' Z ')/3600;
echo gmdate (' Z ')/3600;
If the output is the same, your time is GMT
------Solution--------------------
Because you did not set the local time zone, if you set the php.ini in the Date.timezone or with Date_default_timezone_set ()
Set the local time zone, the result is 8.
------Solution--------------------
You are using the default green time. So 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.