I have to do calculates with GMT date, but it looks like there is a bug, or I dont understand something.
echo date('Y-m-d H:i:s').'<br>';
$time = strtotime(date('Y-m-d H:i:s'));
// calculations will come
$time = date('Y-m-d H:i:s', $time);
echo $time.'<br>';
this prints the same dates, as it was expected. But this:
echo gmdate('Y-m-d H:i:s').'<br>';
$time = strtotime(gmdate('Y-m-d H:i:s'));
// calculations will come
$time = gmdate('Y-m-d H:i:s', $time);
echo $time.'<br>';
is not the same. What am I doing wrong? I have to use GMT time, its an international site.
strtotime
uses the local time zone, unless the passed string has timezone information. Dates of the format 'Y-m-d H:i:s'
do not contain time zone information.
In strtotime(gmdate('Y-m-d H:i:s'))
, the function strtotime
assumes that the passed string specifies a date in the local timezone, but it actually is in GMT.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments