Get number of years, months, days, minutes from number of minutes

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Get number of years, months, days, minutes from number of minutes



How to get the total number of monts, days, and minutes from a given minute. Say for example given a value in minutes 93366 should return 2 months ,5 days and 5 hours. This is what I've tried so far.


93366


2 months ,5 days and 5 hours


function convert_minutes($minutes, $output)
if ($minutes >= 43833)
$whole_month = 0;
$decimal_month = 0;
$label = "";
$months = $minutes / 43833;
list($whole_month, $decimal_month) = sscanf($months, '%d.%d');
if ($months > 1)
$label = "months";
else
$label = "month";

$output .= $months . " " . $label;
$decimal_month = "0." . $decimal_month;
if ($decimal_month != 0)
return $this->convert_minutes($decimal_month, $output);
else
return $output;

elseif ($minutes >= 1440)
$whole_day = 0;
$decimal_day = 0;
$label = "";
$days = $minutes / 1440;
list($whole_day, $decimal_day) = sscanf($days, '%d.%d');
if ($days > 1)
$label = "days";
else
$label = "day";

$output .= $days . " " . $label;
$decimal_day = "0." . $decimal_day;
if ($decimal_day != 0)
return $this->convert_minutes($decimal_day, $output);
else
return $output;

elseif ($minutes >= 60)
$whole_minutes = 0;
$decimal_minutes = 0;
$label = "";
$min = $minutes / 60;

list($whole_minutes, $decimal_minutes) = sscanf($min, '%d.%d');
if ($min > 1)
$label = "minutes";
else
$label = "minute";

$output .= $min . " " . $label;
$decimal_minutes = "0." . $decimal_minutes;
if ($decimal_minutes != 0)
return $output . " and " . $decimal_minutes . " minutes";
else
return $output;





EDIT



I just wanted to get the estimate. Assuming 1 hour is 60 minutes and 1 day is 1440 minutes and 1 month is 43,200. I am developing a document tracking system and would just like to calculate how long a document stayed in a particular office based on the date received and date released.





Minutes to months can't be done, a month doesn't have a set number of days. e.g. Feb has 28/29, March has 31, April has 30. If you define a "month" as always 30 days it could be done.
– user3783243
6 mins ago






I just wanted to get the estimate. Assuming 1 hour is 60 minutes and 1 day is 1440 minutes and 1 month is 43,200. I am developing a document tracking system and would just like to calculate how long a document stayed in a particular office.
– beginner
2 mins ago









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard