How is PHP $ _SERVER [REQUEST_TIME] installed?

What happens on the server to set the request time? Does the timezone for which the server is configured take into account?

I ask because I need to know if I have a site on which the time zone is set as a site variable, and I compare something with $_SERVER['REQUEST_TIME'] to find out if this has expired, I'm not sure maybe Is there a time zone mismatch.

+7
source share
1 answer

$_SERVER 'REQUEST_TIME' is a Unix timestamp. This should be enough information, but if it is not: Unix timestamps are always based on UTC.

PHP example

The Unix timestamp in DateTime is the number prefix with the at sign (" @ "). Then, the second parameter $timeZone and defaults to “ UTC ”, since this is a Unix timestamp that is always based on UTC:

 $requestTime = new DateTime("@$_SERVER[REQUEST_TIME]"); 

gives:

 class DateTime#1 (3) { public $date => string(19) "2013-06-23 07:45:44" public $timezone_type => int(1) public $timezone => string(6) "+00:00" } 

It is impossible to force (by the timestamp when building) the DateTime object to switch to another time zone - only later change the time zone .

+10
source

All Articles