Php 计算日期之间的差异
我需要您的帮助,以了解如何在以下数组中减去上次修改的Php 计算日期之间的差异,php,arrays,Php,Arrays,我需要您的帮助,以了解如何在以下数组中减去上次修改的和最终手稿日期: 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 )
和最终手稿日期:
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
)
因此,在这种情况下,我可以得到2010-12-21和2010-09-27之间N天的值。您检查过STROTIME吗
你查过时间了吗
如果您有5.3+:
$date1 = new DateTime("2010-09-27");
$date2 = new DateTime("2010-12-21");
$interval = $date1->diff($date2);
echo $interval->d //returns days.
如果你有5.3+:
$date1 = new DateTime("2010-09-27");
$date2 = new DateTime("2010-12-21");
$interval = $date1->diff($date2);
echo $interval->d //returns days.
你不能简单地做:
$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
你不能简单地做:
$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