未来 20 年的日期被视为无效

Dates 20 years in the future considered invalid

Laravel 验证器不接受未来超过 20 年的日期:

Route::get('test', function() {
    $input = ['date' => '2039-01-01'];
    $rule = ['date' => 'date'];
    $v = \Illuminate\Support\Facades\Validator::make($input, $rule);
    return 'Fails: '.$v->fails();
});

尽管日期是正确的,但以下示例 return 是正确的。但是当我将 2039 更改为 2037 时,它起作用了。我怎样才能使验证器始终 return 为假?

来自 Unix time 上的维基百科:

On systems where the representation of Unix time is as a signed 32-bit number, the representation will end after the completion of 2,147,483,647 (2^31 - 1) seconds from 00:00:00 on 1 January 1970, which will happen on 19 January, 2038 UTC, with the exact time depending on the unpredictable leap seconds. This is referred to as the "Year 2038 problem" where the 32-bit signed Unix time will overflow and will take the actual count to negative.

来自Laravel Validation docs

date

The field under validation must be a valid date according to the strtotime PHP function.

这似乎取决于 PHP 被编译为使用 32 位时间戳还是 64 位时间戳(参见讨论 here)。如果你有一个 32 位的 PHP,你唯一的前进方向是编写你自己的验证器,这不依赖于 PHP 的日期解析(或移动到 64 位 PHP).