Checking a valid date entered by user in PHP
Many times we have to check the date entered are in correct format or not. The combination of entered month date and year by a user has to be a valid date to use in our applications. Even if we give a selection or a drop down list box to select a datewe have to check the combination of month, day and year selection is valid or not. User may select 29th Feb 2005 (which is not a leap year ) or it may select 31st Nov of any year. So the combination has to be checked.For this PHP has a checkdate() function which takes care of leap year checking also. This function validates the date and returns true if date is correct or false if date is wrong or does not exist. Here is the format
int checkdate (int month, int day, int year)
If you are using the drop down date combination for selection or asking to enter date in a format, better to validate date by using checkdate function.
Here is the case where checkdate will return false
0 comments:
Post a Comment