Does anyone know how to pass a given variable instead the Carbon's default parameters ?
The documentation of Carbon says:
// CARBON SAMPLE
$dtToronto = Carbon::createFromDate(2012, 1, 1, 'America/Toronto');
$dtVancouver = Carbon::createFromDate(2012, 1, 1, 'America/Vancouver');
echo $dtVancouver->diffInHours($dtToronto); // 3
And i want to do something like this in my controller:
// EXAMPLE
$date = "2016-09-16 11:00:00";
$datework = Carbon::createFromDate($date);
$now = Carbon::now();
$testdate = $datework->diffInDays($now);
And retrieving that on a Blade template
// VIEW ON BLADE
<td> {{ $testdate }} </td>
new Carbon($date)
instead ofCarbon::createFromDate($date)
. – LavalleeCarbon::parseDate($date);
insted ofcreateFromDate
– Naucratis<td>{{Carbon\Carbon::now()->diffInDays($work['date']) }}</td>
but i have this error:Type error: Argument 1 passed to Carbon\Carbon::diffInDays() must be an instance of Carbon\Carbon, string given
. So i have the variable $work['date'] that is a result from the Model query and not a Carbon Object... – Bell