-
- /*
- *
- *Function function: Calculate the difference of two dates in YYYY-MM-DD format by how many days
- *
- */
- function getChaBetweenTwoDate($date1,$date2 ){
- $Date_List_a1=explode("-",$date1);
- $Date_List_a2=explode("-",$date2);
$d1=mktime(0,0,0,$Date_List_a1[1 ],$Date_List_a1[2],$Date_List_a1[0]);
- $d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]);
- $Days= round(($d1-$d2)/3600/24);
- return $Days;
- }
echo getChaBetweenTwoDate('2010-08-11','2010-08-16' );
- echo "
";
- echo getChaBetweenTwoDate('2010-08-16','2010-08-11');
- ?>
-
Copy code
|