From Convert seconds into days, hours, minutes and seconds we can get the good function of User Galvic:
function secondsToTime($seconds){
$dtF = new \DateTime('@0');
$dtT = new \DateTime("@$seconds");
return $dtF -> diff($dtT) -> format('%a days, %h hours, %i minutes and %s seconds');
}
echo secondsToTime(3600 * 24 * 31);
and this work greath!, but I want add months, then I put %m months return 0, and %M months return two digits.
How to convert 3600 * 24 * 32
in [1 month and 2 day] and 3600 * 24 * 30 * 13
in [1 year and 1 month]?
Becosue in Function of Galvic exist many options, but only ONE using 2 lines: GALVIC function, then I want add to this two lines the option "months, year".
Thanks