Timestamp conversion exception with Carbon

Posted 6 months ago by bwrigley

Hi There,

I have hit a strange problem with timestamp conversion in a Blade file, but I'm not sure if this is a Blade/Laravel/Carbon or PHP issue.

I can replicate the problem in tinker using either the \Carbon\Carbon lib or the illuminate\Support\Carbon lib

So the problem is that this command:

\Carbon\Carbon::parse('1544690366')->format('d/m/Y')

dies with this error:

Exception with message 'DateTime::__construct(): Failed to parse time string (1544690366) at position 8 (6): Unexpected character'

However swap out that 6 for another number and:

\Carbon\Carbon::parse('1544590366')->format('d/m/Y'); 18/12/0366

But that's not right either!

I'm sure I'm missing something really obvious here, but have you got any thoughts?

Please sign in or create an account to participate in this conversation.