使用 DateTime:(您将希望更好地格式化结果)
$q = new DateTime('2013-10-11 10:10:11');
$w = new DateTime('2013-11-18 14:13:16');
$result = $w->diff($q);
$string = "This task took ";
if ($result->y > 0) {$string .= $result->y.' years, ';}
if ($result->m > 0) {$string .= $result->m.' months, ';}
if ($result->d > 0) {$string .= $result->d.' days, ';}
if ($result->h > 0) {$string .= $result->h.' hours, ';}
if ($result->i > 0) {$string .= $result->i.' minutes, ';}
if ($result->s > 0) {$string .= $result->s.' seconds ';}
$string .= "to complete.";
echo $string;