Carbon subtracting Datetime from Carbon::now()

datetime, php

Solution

I know it's a bit late, but this works:

$score->created_at->diffForHumans(\Carbon\Carbon::now())

Problem

I want to use this Carbon function: Carbon::now()->subDays(5)->diffForHumans() And I need to create the correct integer. I am loading a string with a Datetime, which I want to subtract in Laravel like this: ``` $datetime = $score->created_at; ``` Then I save the current Time into a variable ``` $now = Carbon::now()->toDateTimeString(); ``` This is what I get: ``` echo $now . '<br>'; // 2014-07-13 22:53:03 echo $datetime; // 2014-07-12 14:32:17 ``` But when I want to subtract one from another I get the following error: ``` echo $now - $datetime; ``` Object of class Carbon\Carbon could not be converted to int Any help here would be greatly apreciated.

Original source