Home » questions » why my mktime() never work? I am trying to count day between arrival date and departure date?

why my mktime() never work? I am trying to count day between arrival date and departure date?

2006-08-17 00:44:26, Category: Programming & Design
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?

Answers

  1. hswes

    On 2006-08-17 01:56:38


    Just Try it this way Helmut