note 111339 modified in function.date-diff by danbrown
| From: | danbrown@php.net | Date: | Tue, 05 Mar 2013 16:10:51 +0000 |
| Subject: | note 111339 modified in function.date-diff by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193923@lists.php.net to get a copy of this message | ||
here a little solution of problem of missing date_diff function with php versions below 5.3.0
<?php
function IntervalDays($CheckIn,$CheckOut){
$CheckInX = explode("-", $CheckIn);
$CheckOutX = explode("-", $CheckOut);
$date1 = mktime(0, 0, 0, $CheckInX[1],$CheckInX[2],$CheckInX[0]);
$date2 = mktime(0, 0, 0, $CheckOutX[1],$CheckOutX[2],$CheckOutX[0]);
$interval =($date2 - $date1)/(3600*24);
// returns numberofdays
return $interval ;
}
?>
--was--
here a little solution of problem of missing date_diff function with php versions below 5.3.0
function IntervalDays($CheckIn,$CheckOut){
$CheckInX = explode("-", $CheckIn);
$CheckOutX = explode("-", $CheckOut);
$date1 = mktime(0, 0, 0, $CheckInX[1],$CheckInX[2],$CheckInX[0]);
$date2 = mktime(0, 0, 0, $CheckOutX[1],$CheckOutX[2],$CheckOutX[0]);
$interval =($date2 - $date1)/(3600*24);
// returns numberofdays
return $interval ;
}
http://php.net/manual/en/function.date-diff.php