年份以PHP返回1970年[重复]

This question already has an answer here:

The below code returns 1970 if the year is 2038 and correct year (2037) if it is altered as 2037. why?

$date = '28/05/2038';
$date = strtr($date, '/', '-');
$year = date('Y', strtotime($date));
echo $year;

I did some research and understood that the strtotime conversion returns 0, when the passed value is unsupported and hence this happens. But I dont understand how will it become unsupported if I change the date from '28/05/2038' to '28/05/2037'.

</div>

It seems the problem is easily repeated for PHP versions below 5.2.16 even with even with PHP_INT_SIZE = 8. For that version and above the code executes correctly. Upgrading PHP to 5.2.16 should solve it. Only tested for PHP_INT_SIZE = 8 (64 bit)

Here you can check for yourself.

If you happen to be on PHP 5.2.0 or higher (but below 5.2.16) you can go for DateTime class as others suggested in the question's comments.

Note: Upgrading a service on a populated server may not be possible, not on work and not even on university courses. But if it happens to be possible, then you should test the proper version of PHP before upgrading. If it works, you should investigate why it has been fixed and at which point the functionality was added, googling PHP's bugtracker. Then suggest the change.