Validate the date


/ Published in: PHP
Save to your folder(s)

This will check the date and if it is not a valid date then it will increment the month and reset the day back to one.


Copy this code and paste it in your HTML
  1. Check date function
  2. //Check the date
  3. while(!checkdate($month, $day, $year)){
  4. if($month <= 12 && $day <=31){
  5. $month++;
  6. $day = 1;
  7. }else{
  8. $year++;
  9. $month = 1;
  10. $day = 1;
  11. }
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.