Please tell me if following answer is correct
Question : User has filled a form where he had to put date of birth , need to code a couple of php statement which should do verification of date of birth , if the date of birth of birth is in future date from today then an error should come up .
answer:
$dob = $day . $month . $year; // this will combine day , month and year as they were taken as different values
if $now < $dob; // this is if statement which matches NOW time with input dob
echo " Please enter correct date of birth";
if compare statement
Moderator: General Moderators
Re: if compare statement
$now isn't defined.
11032014 > 10102222
11032014 > 10102222
Re: if compare statement
If i have to define current time using now variable I could put
$now = "2014-03-22"
and then do the comparison , would this be correct ?
$now = "2014-03-22"
and then do the comparison , would this be correct ?
Re: if compare statement
So long as you remember to order them both the same, that should work fine. Rather than hardcoding a date as $now, though, wouldn't it make more sense to use, say, date('Y-m-d')?