Can anybody help me in count the number of night for guests stay? Example arrival date is 28-09-2006 and departure date is 30-09-2006. That means this guest is staying for 2 nights. I doing mktime() izit correct? My coding is:
$first_date_ex = explode("-",$arrive);
$second_date_ex = explode("-",$depa);
// makes the dates and times into unix timestamps.
$first_unix = mktime($first_date_ex[1], $first_date_ex[2], $first_date_ex[0]);
$second_unix = mktime($second_date_ex[1], $second_date_ex[2], $second_date_ex[0]);
// Gets the difference between the two unix timestamps.
$timediff = $second_unix-$first_unix;
$days=intval($timediff/86400);
$remain=$timediff%86400;
echo $days;
but when i echo $days, i get value "0". why? my coding correct or not?
2006-08-16
20:44:26
·
2 answers
·
asked by
183
1
in
Programming & Design