Hello
I am having problems comparing two dates.
I have this code
<?php
$exp_date="22-01-2008";
# creates Unix timestamp time for date('d-m-Y')
$server_date=date('d-m-Y');
$server_date_array=explode("-",$server_date);
$server_date=mktime (0,0,0,$server_date_array[1],$server_date_array[0],$server_date_array[2],0);
# creates Unix timestamp for $exp_date
$exp_date_stamp_array=explode("-",$exp_date);
$exp_date_stamp=mktime (0,0,0,$exp_date_stamp_array[1],$exp_date_stamp_array[0],$exp_date_stamp_array[2],0);
# compare Unix timestamp
if ( $exp_date_stamp <= $server_date ) {
echo "EXPIRED" ;
}
else
{
echo "VALID" ;
}
?>
It creates a Unix timestamp for date() and $exp_date
then compare the 2 Unix timestamp to verifiy if $exp_date is valid or expired (compared with current date)
It works on my computer without problems (returning VALID) .
On some unix server where the server date was
Tue Feb 27 01:56:46 WIT 2007
the scripts returned EXPIRED instead of VALID .
Anyone can tell me why ? What's wrong on my code ?
Thank you!