InvalidArgumentException PHP 8.2.11 10.32.1 “now – 72000000000000 seconds” is not a valid date [closed]

Hello StackOverflow Community,

I am currently encountering a perplexing issue in my PHP 8.2.11 production environment, and despite several attempts, I have been unable to resolve it completely. The error message I’m encountering is:

InvalidArgumentException: PHP 8.2.11 10.32.1 “now – 72000000000000 seconds” is not a valid date

This issue seems to occur sporadically in my live production environment, while the code works flawlessly in my local environment.

The primary concern is related to the generation of a slug using the Laravel SlugService and now() function. To mitigate the problem, I initially used the following code:

$slug = SlugService::createSlug(AppModelsCompany::class, 'slug', $request->name) . '-' . now()->format('YmdHis');

In an attempt to mitigate the issue, I modified the code as follows:

$slug = Str::slug($data['name']) . '-' . mt_rand(100000000, 999999999);

Regrettably, the error still persists sporadically in the live production environment. I have thoroughly reviewed all date-related options, but the problem persists.

I am reaching out to seek guidance on potential solutions or insights into why this error might be occurring inconsistently in a live production environment.

error