// This conversion is based on the average number of days in a year,
// which is about 365.2425 days.
function daysToYMD(int $days): string {
$start = new DateTime("1970-01-01");
$end = (clone $start)->modify("+$days days");
$diff = $start->diff($end);
return sprintf(
"%d year%s, %d month%s and %d day%s",
$diff->y, $diff->y === 1 ? "" : "s",
$diff->m, $diff->m === 1 ? "" : "s",
$diff->d, $diff->d === 1 ? "" : "s"
);
}
echo daysToYMD(452) . PHP_EOL;
/*
run:
1 year, 2 months and 28 days
*/