2010-07-27 286 views

回答

3
$totalmonths = 26; 
$years = floor($totalmonths/12); 
$months = $totalmonths % 12; 
echo $years, " year", $years==1?"":"s"; 
if ($months != 0) 
    echo " and ", $months, "month", $months==1?"":"s"; 
+0

這個工程,非常感謝! – lam3r4370 2010-07-27 19:18:04

2

除以12並分別取整數部分和模數。

+0

我試過這個.Number 16 - 1.333(3)。但是它是1年零4個月 – lam3r4370 2010-07-27 19:17:36