amrnn90 / laravel-cursor-paginator

Cursor pagination for Laravel
MIT License
19 stars 7 forks source link

Use Carbon::createFromTimestamp for parsing timestamps #1

Closed trevorgehman closed 5 years ago

trevorgehman commented 5 years ago

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:

https://github.com/briannesbitt/Carbon/issues/837#issuecomment-270327519

amrnn90 commented 5 years ago

Thank you @trevorgehman