Search code examples
phpdatephp-carbon

PHP Carbon take number of minutes & convert to days


I am trying to convert a number on minutes into number of days using Carbon.

$minutes = 1400;

I want to do something like below (which of course, does not work):

Carbon->minutes($minutes)->days();

I cannot find an example of this. Thanks for any help.


Solution

  • Not tested, but a quick look at the docs suggests it might be aimed more at DateTime objects than differences in time, so you could do something like this:

    $now  = Carbon::now();
    $days = $now->diffInDays($now->copy()->addMinutes($minutes));