note 92351 rejected from function.date-parse by thiago
| From: | thiago@php.net | Date: | Tue, 21 Jul 2009 12:03:53 +0000 |
| Subject: | note 92351 rejected from function.date-parse by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158533@lists.php.net to get a copy of this message | ||
Note Submitter: mhd dot azeem at gmail dot com
----
<?php
// get difference of dates in days.
function getDayDifference($start_date, $end_date) //YYYY-MM-DD, YYYY-MM-DD
{
$difference=0;
if ($start_date<>'' && $end_date<>'') {
$array_start = date_parse($start_date);
$start_year = $array_start["year"];
$start_month = $array_start["month"];
$start_day = $array_start["day"];
$array_end = date_parse($end_date);
$end_year = $array_end["year"];
$end_month = $array_end["month"];
$end_day = $array_end["day"];
$date_start=mktime(0,0,0,$start_month,$start_day,$start_year);
$date_end=mktime(0,0,0,$end_month,$end_day,$end_year);
$difference=$date_end-$date_start;
$difference=floor($difference/(60*60*24));//Days.
//$difference=floor($difference/(60*60*24*352));//Years.
}
return $difference;
}
?>
is there a batter way to do this????