I need a regular expression in javascript that can test for dates with the following formats:
- yyyy-MM-dd (Example: 2014-12-31)
- dd.MM.yyyy (Example: 31.12.2014)
- dd.MM.yy (Example: 31.12.14)
- ddMMyyyy (Example: 12312014)
- ddMMyy (Example: 123114)
- dd.M.yy (Example: 12.6.14)
- dd.M.yyyy (Example: 12.6.2014)
Sorry, but I am really terrible at regular expressions. This is probably a breeze for a pro. Thanks a milion.
99.33.8888a valid date?ddMMyyyy (Example: 12312014)is incorrect: '31' is the day, and '12' is the month, so it should beMMddyyyyor the example should be rewritten.ddMMyy (Example: 123114)is incorrect: same reason. And if you're consistent with your "Example" formatting, '12' is always representing the MONTH, not the DAY, and either31or6should be the DAY. Could you modify the post to reflect the correct format (or the correct Example)?