在 32 位系统上,可以在 INT 中保存的最大值是 2147483647。
http://php.net/manual/en/language.types.integer.php
如果你的本地机器是 64 位的,而你的服务器是 32 位的,它们会有不同的大小限制。服务器将无法处理像 201203140906 这样大的整数。
您可以随机生成一个较小的数字,然后将其添加到 201203140906。
或许像这样:
$today = date('YmdHi');
$startDate = date('YmdHi', strtotime('2012-03-14 09:06:00'));
$range = $today - $startDate;
$rand = rand(0, $range);
echo "$rand and " . ($startDate + $rand);
或者您可以这样做以在过去十天内生成随机日期:
$today = date('YmdHi');
$startDate = date('YmdHi', strtotime('-10 days'));
$range = $today - $startDate;
$rand = rand(0, $range);
echo "$rand and " . ($startDate + $rand);