同样的时间段,在不同的时区下,转换成秒以后居然会不相等。
date_default_timezone_set('America/Los_Angeles'); echo 'America/Los_Angeles'; echo "\n"; $start = strtotime('2010-12-20 00:00:00'); echo $start; echo "\n"; $end = strtotime('2011-04-05 00:00:00'); echo $end; echo "\n"; $offset1 = $end - $start; echo $offset1; echo "\n"; date_default_timezone_set('Asia/ShangHai'); echo 'Asia/ShangHai'; echo "\n"; $start = strtotime('2010-12-20 00:00:00'); echo $start; echo "\n"; $end = strtotime('2011-04-05 00:00:00'); echo $end; echo "\n"; $offset2 = $end - $start; echo $offset2; echo "\n"; echo $offset2 - $offset1;
运行结果如下:
X-Powered-By: PHP/5.2.0