Carbon::parse() doesn't work with timestamps in some versions. I'm running 1.39.0 and it gives me an exception:
>>> Carbon::parse(1566247955);
Exception with message 'DateTime::__construct(): Failed to parse time string (1566247955) at position 7 (9): Unexpected character'
The solution is either to append a @ to the timestamp Carbon::parse('@' . 1566247955) or use Carbon::createFromTimestamp().
The recommendation from Carbon is the latter. See the comments here for more information:
Carbon::parse()
doesn't work with timestamps in some versions. I'm running1.39.0
and it gives me an exception:The solution is either to append a
@
to the timestampCarbon::parse('@' . 1566247955)
or useCarbon::createFromTimestamp()
.The recommendation from Carbon is the latter. See the comments here for more information:
https://github.com/briannesbitt/Carbon/issues/837#issuecomment-270327519