Reputation: 642
I need your help in how to subtract the last_modified
and the final_manuscript_date
in the following array:
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
)
So I can in this case get a value of N days between the dates 2010-12-21 and 2010-09-27?
Upvotes: 0
Views: 49
Reputation: 785286
Can't you simply do:
$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
Upvotes: 2
Reputation: 73312
If you have 5.3+:
$date1 = new DateTime("2010-09-27");
$date2 = new DateTime("2010-12-21");
$interval = $date1->diff($date2);
echo $interval->d //returns days.
Upvotes: 1
Reputation: 746
Have you checked strtotime?
http://php.net/manual/en/function.strtotime.php
Upvotes: 0