0

I have found this function to convert seconds to day, months,.. but how to calculate the number of years?

function seconds2human($ss) {
   $s = $ss%60;
   $m = floor(($ss%3600)/60);
   $h = floor(($ss%86400)/3600);
   $d = floor(($ss%2592000)/86400);
   $M = floor($ss/2592000);

   return "$M months, $d days, $h hours, $m minutes, $s seconds";
}
Fury
  • 4,643
  • 5
  • 50
  • 80
  • function secondsToTime($ss) { $M = floor(($ss%31536000)/2592000); // Months $Y = floor($ss/31536000); // Years if ($Y>0){ $time .= "$Y years "; } if ($M>0){ $time .= "$M months"; } $time = empty($time)?"-":$time; return $time; } – Fury Feb 03 '15 at 09:32
  • here is the answer for the others to know – Fury Feb 03 '15 at 09:33

0 Answers0