2012-01-03 156 views
0

我需要你如何減去last_modified幫助和下面的陣列中的final_manuscript_date計算差異

Array ( 
    [chapters_id] => 10736 
    [last_modified] => 2010-12-21 15:01:55 
    [steps_id] => 3 
    [sub_step_id] => 0 
    [steps_position] => 1 
    [final_manuscript_date] => 2010-09-27 
) 

所以我可以在這種情況下獲得的N天的日期2010-12之間的值-21和2010-09-27?

回答

2

不能你根本:

$diff = strtotime($arr["final_manuscript_date"]) - strtotime($arr["last_modified"]); 
$days = $diff/84600; // to get # of days, you can round them off or use ceil/floor 
1

如果你有5.3+:

$date1 = new DateTime("2010-09-27"); 
$date2 = new DateTime("2010-12-21"); 
$interval = $date1->diff($date2); 
echo $interval->d //returns days.