Home > PHP > Date validation in PHP

Date validation in PHP

What happens if a user enters as birthday 31/02/2000.?
Is the date will be properly stored in the database?

Of course not. 03.03.2000 will be saved, because we have 3 days exceeded the number of days in February. It would be nice to warn him of the mistake. To do this, they would have to make a function that would control date.

PHP already has a function to check the validity date:

bool checkdate(int $month, int $day, int $year);

For the month, day and year, the function will return if the date is correct or not.

Categories: PHP Tags: ,
  1. No comments yet.
  1. No trackbacks yet.