$timeStr='1987-5-4'; echo '测试时间:'.$timeStr; echo PHP_EOL; $prcTime=strtotime($timeStr); echo 'PRC时间:'; echo $prcTime; echo PHP_EOL; date_default_timezone_set('UTC'); $utcTime=strtotime($timeStr); echo 'UTC时间:'; echo $utcTime; echo PHP_EOL; echo 'UTC与PRC时间相差:'.(($utcTime-$prcTime)/3600).'小时'; echo PHP_EOL;
Result:
Test time: 1987-5-4
PRC time:547052400
UTC time: 547084800
UTC and PRC time Difference: 9 hours
After testing, the difference between UTC and PRC time for dates from 1987 to 1991 is 9 hours.
The php version is
PHP 7.1.9 (cli) (built: Aug 30 2017 18:34:46) (ZTS MSVC14 (Visual C 2015) x64)
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
Forgot to ask the question, what is the reason for this? How to deal with this bug?