first I use Carbon\Carbon; then I try to echo difforhumans reference by doc : https://carbon.nesbot.com/docs/#api-humandiff
echo Carbon::parse('2019-08-03')->diffForHumans('2019-08-13');
laravel 5.5 said Parse error: syntax error,
UPDATE
I install laravel 5.6 but I downgrade into 5.5
here is my full code
use Carbon\Carbon;
public function index(Request $request)
{
dd(\Carbon\Carbon::parse('2019-08-03')->diffForHumans('2019-08-13'));
}
First of all diffForHumans
don't take any arguments.If just removing the date from diffForHumans
won't work..
Try this:
use Carbon\Carbon;
public function index(Request $request)
{
dd(Carbon::createFromFormat('Y-m-d','2019-08-03')->diffForHumans());
}