PHP timestamp problem mktime Gmmktime

Source: Internet
Author: User
I want to get timestamp, see there are two methods Mktime () and Gmmktime (), one is to get local timestamp, one is UTC timestamp, I print out, timestamp is the same, not should be 8 hours apart, the local timestamp is Beijing time. Can you explain that?

Reply content:

I want to get timestamp, see there are two methods Mktime () and Gmmktime (), one is to get local timestamp, one is UTC timestamp, I print out, timestamp is the same, not should be 8 hours apart, the local timestamp is Beijing time. Can you explain that?

With all due respect, the timestamp is not all UTC, so the local time will be ignorant after formatting.

Looked at, the difference between these two functions is the processing of the parameters passed in. The mktime default is local time, which defaults to GMT gmmktime (GMT).

For example, the other answers above, mktime(1,50,15,4,15,2012) return the time stamp of local time April 15, 2012 1:50 15 seconds, gmmktime(1,50,15,4,15,2012) return is GMT April 15, 2012 1:50 15 seconds timestamp, so the natural result is different.

The local time zone is the php.ini option in the pass date.timezone , or the function is called date_default_timezone_set to set it.

If you omit the parameter, the default is the current time , which is the same (even if you set the time zone, the timestamp is UTC-based).

If you just want to get the current timestamp, we recommend using a time function. The above two functions are primarily used to obtain a specific local time or GMT corresponding to the timestamp.

is the parameter wrong or what, my side is normal


  
   ';echo gmmktime(1,50,15,4,15,2012);

Does local PHP have time to set up East zone eight?

http://www.cnblogs.com/mxw09/...

This link should be explained very clearly.


  
   

传入具体的开始时间才对

不然默认传入之后会转化导致相同.

  • 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.