I want to convert time interval in seconds into days hours minutes. I have tried this.
$value = '90060';
CarbonInterval::seconds($value)->forHumans();
I got the output
90060 seconds
My expected output is
1 day 1 hour 1 minute
How can I get the output using Carbon
or CarbonInterval
I got a solution.
$value = '90060';
$dt = Carbon::now();
$days = $dt->diffInDays($dt->copy()->addSeconds($value));
$hours = $dt->diffInHours($dt->copy()->addSeconds($value)->subDays($days));
$minutes = $dt->diffInMinutes($dt->copy()->addSeconds($value)->subDays($days)->subHours($hours));
echo CarbonInterval::days($days)->hours($hours)->minutes($minutes)->forHumans();
Updated Solution
CarbonInterval::seconds(90060)->cascade()->forHumans();