What happens on the server to set the request time? Does it take into account the timezone for which the server is configured?
I'm asking because I need to know, if I have a site that has a timezone set as a site-wide variable, and I compare something to the $_SERVER['REQUEST_TIME']
to know if it's expired, I'm not sure whether a timezone mismatch is possible.
$_SERVER
's 'REQUEST_TIME'
is a Unix timestamp. That should be enough information, but if it isn't: Unix timestamps are always UTC-based.
The notation for Unix timestamps in DateTime
is to prefix the number with the at-sign ("@
"). Then the second $timeZone
parameter is ingored and defaults to "UTC
" because it is a Unix timestamp which are always UTC based:
$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 not even possible to force (by timestamp at construction) the DateTime
object to a different timezone - only later on changing the timezone.