Instructions. Write a PHP script that uses regular expressions to validate that a date is in the proper format for inserting into a MySQL database. For the sake of this assignment, let's say that valid dates should: be in the format YYYY-MM-DD be between the year 1900 and 2023 . have a month between 01 and 12 . have a day between 01 and 31 Note: it's okay if a month has an invalid day at this point (e.g., 2010-02-30 should still be a valid date with your regular expression, but 2010-02-47 is not). Create an array to store at least 4 valid dates and at least 3 invalid dates (feel free to use the ones in the sample below). Loop through the array and, using the preg_match function, determine whether the date is valid or not and print an appropriate statement. Here is some sample output: 2020-01-19 is a valid date. 0000-01-01 is not a valid date. 1801-10-08 is not a valid date. 1900-03-02 is a valid date. 2023-12-17 is a valid date. 2021-13-09 is not a valid date. 2010-04-01 is a valid date. 2023-1-2 is not a valid date. Remember that preg_match returns O if the string does not match the pattern and 1 if it does. Make use of https://regex101.com/ to test your pattern, if you'd like.
Instructions Write a PHP script that uses regular expressions to validate that a date is in the proper format for inserting into a MySQL database. For the sake of this assignment. let's say that valid dates should:
be in the format YYYY-MM-DD be between the year 1900 and 2023 have a month between 01 and 12 have a day between 01 and 31
Note:it's okay if a month has an invalid day at this point (e..2010-02-30 should still be a valid date with your regular expression,but 2010-02-47 is not).
Create an array to store at least 4 valid dates and at least 3 invalid dates (feel free to use the ones in the sample below.Loop through the array and,using the p reg mat ch function.determine whether the date is valid or not and print an appropriate statement.
Here is some sample output:
2020-01-19 is a valid date
0000-01-01 is not a valid date
1801-10-08 is not a valid date
1900-03-02 is a valid date
2023-12-17is a valid date
2021-13-09 is not a valid date
2010-04-01 is a valid date
2023-2is not a valid date
Remember that preg_mat ch returns O if the string does not match the pattern and1 if it does.
Make use of https://regex101.com/to test your pattern,if you'd like