Easy way to convert datetime value in Laravel
If you’re working with dates in Laravel, chances are you’ll need to convert them to another format at some point.
For instance, you might need to display a date in a human-friendly format like “July 1, 2020” or convert it to a different timezone.
Let’s say we have a timestamp in the following format:
We can convert this to a human-friendly format using the Carbon::parse() method:
$date = Carbon::parse(‘2020–07–01 00:00:00’);echo $date->toDateString(); // outputs “July 1, 2020”
We can also convert this timestamp to a different timezone using the Carbon::
Laravel collection sort by
Do you know that Laravel provide some function that let us easily to do sorting for our collection?