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.
传入具体的开始时间才对
不然默认传入之后会转化导致相同.