Background: our server PHP set timezone to America/Los_Angeles
At work, I found this piece of code
$a = 1457856000;
$b = $a + 24*3600-1;
var_dump(date('Y-m-d H:i:s', $a));
var_dump(date('Y-m-d H:i:s', $b));
which output:
string(19) "2016-03-13 00:00:00"
string(19) "2016-03-14 00:59:59"
quite strange, but when I code as follow:
date_default_timezone_set('Etc/GMT+8');
$a = 1457856000;
$b = $a + 24*3600-1;
var_dump(date('Y-m-d H:i:s', $a));
var_dump(date('Y-m-d H:i:s', $b));
it output:
string(19) "2016-03-13 00:00:00"
string(19) "2016-03-13 23:59:59"
Could anyone explain why this happened?