Reputation: 1
hello I have some trouble with comparing dates.
in my php validation script, this is the client's birthday.
$bdate = $_POST['year'].'-'.$_POST['month'].'-'.$_POST['day'];
this is today's date:
$cdate = date("Y-m-d");
this is the validation part:
if($bdate > $cdate)
{
die('{status:0,txt:"Please check your birthday"}');
}
When the birthday's year and today's year are not the same like (different than 2011) it works. However when the birthday's year and today's year are the same (both 2011) the validation part can't compare these to dates. Example, if $bdate is 2011-01-01 and $cdate is 2011-05-31
if($bdate > $cdate)
{
die('{status:0,txt:"Please check your birthday"}');
}
returns true.
Help needed.
Upvotes: 0
Views: 226
Reputation: 168843
As per my comment, have you confirmed that all components of the date from $_POST are the correct length? -- eg no single-digit months or days. That could mess it up.
Upvotes: 1