PHP Carbon take number of minutes & convert to days

后端 未结 2 666
情歌与酒
情歌与酒 2021-01-22 18:27

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 cours

相关标签:
2条回答
  • 2021-01-22 18:29

    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));
    
    0 讨论(0)
  • 2021-01-22 18:47

    Maybe CarbonInterval::minutes($minutes)->cascade();?

    Will cascade down your value and format it for humans.

    0 讨论(0)
提交回复
热议问题