I have a timestring 1661731200 that works as expected when I parse it with Carbon via artisan tinker or in my code using

$time = "1661731200";
Carbon::parse($time);

Code running on tinker

But the same line of code fails with error Failed to parse time string (1661731200) at position 8 (0): Unexpected character when encountered on the live server.

I'm looking to understand what might be causing this behaviour.

1

There are 1 best solutions below

2
KyleK On

Add the @ timestamp prefix:

$time = "@1661731200";
Carbon::parse($time);

Or it can be:

$time = "1661731200";
Carbon::createFromTimestamp($time);