I know there might be different ways using timestamps and stuff but I'm having trouble converting number of hours into something that human would understand. I do not have power to change anything in the database.
There is a column that holds number of hours, so it can be something like 134.37 hours. Now I can not display that and tell user that something will happen in 134.37 hours I need to convert it into months, days, hours, minutes, seconds.
For example:
Given Hours: 23.33
Desired Result: 0 Months, 0 Days, 23 Hours, 19 Minutes, 48 seconds (dont care about seconds)
Now I need months and days since number of hours might be large. The code I started with does give me number of hours, minutes and seconds but i cant get days and months.
$months = $days = $hour = $min = $sec = 0;
$decimalHours = 23.33;
//convert to hours
$hour = (int)$decimalHours;
$decimalHours -= $hour;
//convert to minutes and subtract minutes
$decimalHours *= 60;
$min = (int)$decimalHours;
$decimalHours -= $min;
$decimalHours = number_format($decimalHours, 10);
//convert to seconds
$decimalHours *= 60;
$sec = (int)$decimalHours;
echo $hour . ' hours, ' . $min . ' minutes, ' . $sec . ' seconds';
Please help if you know a function that does it or an easier way.