Saturday 15 February 2014

php issues with date validation -


It does not matter that I did not try hard, here is what I was looking for:

  $ Dob = '1980-09-04'; Echo $ dob; $ Age = Date ('Y') - Date ('Y', Stratom ($ dob)); Echo $ age; If (date ('md') & lt; date ('md', strotomium ($ dob))) {$ age--; Echo $ age; }  

Sorry for the unnecessary question.

Check for 21 years old .... Is it for pr0n?

First of all, MM / DD / YYYYY is harmful if you are writing something for use internationally! Better to write

  & lt; Select name = 'month' & gt; & Lt; Option value = '01' & gt; January & lt; / Option & gt; .... & lt; Input name = 'day' maximum length = '2' size = '2' /> & Lt; Input name = 'year' maxlength = '4' size = '4' />  

Because we will not be confused with Europeans.

Secondly, you are asking for your DOB and are storing it a parameter & amp; Var name "age" which is cutting you on the ass if you later try to keep the code.

Third, your example data does not match the required input. You tell them an example with separators and then actually process 8 points with no spaces.

Actual Answer: However, if you want to validate the above icky MMDYY YY 8 digit string:

  if (Preg_match ("/ ^ \ d { 8} $ / ", $ dob)) # Failure if there is no string of 8 numerical digits. {....}  

No comments:

Post a Comment