Reputation: 137
I need to check whether the departure-date is after the arrivaldate.
For example:
arrivaldate 13/3/2012 departure 14/3/2012 -> error = false
arrivaldate 13/3/2012 departure 12/3/2012 -> error = true
$timestamp = mktime(0,0,0,$arrivaldd,$arrivalmm,$arrivalyy);
$timestamp2 = mktime(0,0,0,$departuredd,$departuremm,$departureyy);
if ($timestamp2 <= $timestamp) {$error1 = true;} else {$error1 = false;}
It works fine, but $error is set false if arrivaldate is 31/3/2012 and departure date 1/4/2012.
Upvotes: 0
Views: 161
Reputation: 4631
in this function mktime parameters are as follows
mktime(hrs,min,sec,month,day,year)
and you are giving day first and then month.so timestamp generated is departure higher than arrival so you are getting error
Upvotes: 2
Reputation: 360682
That's because mktime's arguments are:
mktime(hours, minute, seconds, month, day, year);
You've got the month/day arguments reversed
Upvotes: 2
Reputation: 11240
mktime
expects is parameters in the following order: hour, minute, second, month, day, year. You have the day and month in reversed order. See the PHP.net reference page
Upvotes: 3