I am using Carbon to get the number of years I've been in FL in a controller and it was working. I came home and suddenly it doesn't work. I don't know what could have changed.
<?php
namespace App\Http\Controllers;
use Carbon\Carbon;
class PageController extends BaseController {
public function showAbout()
{
$livedInFl = Carbon::createFromDate(1997, 08, 15)->diff(Carbon::now())->format('%y');
$realtorFor = Carbon::createFromDate(2006, 03, 14)->diff(Carbon::now())->format('%y');
$grahamAge = Carbon::createFromDate(2011, 11, 29)->diff(Carbon::now())->format('%y');
return view('pages.about', array('grahamAge' => $grahamAge, 'livedInFl' => $livedInFl, 'realtorFor' => $realtorFor));
}
}
I was using this in a blade view and it was showing "Chris has lived in Florida for 19 years" without problem. Suddenly, I run it and I get:
FatalThrowableError in PageController.php line 12:
Parse error: Invalid numeric literal
I've Googled this error and can't find anything that could be the reason so any help is greatly appreciated!
Your code is valid.
Try next decision (remove 0):
$livedInFl = Carbon::createFromDate(1997, 8, 15)->diff(Carbon::now())->format('%y');
$realtorFor = Carbon::createFromDate(2006, 3, 14)->diff(Carbon::now())->format('%y');