Last active
January 22, 2024 06:36
-
-
Save m-coding/c96d99558a47d30aef4992c6dd60437a to your computer and use it in GitHub Desktop.
javascript regex to match date pattern YYYY-MM-DD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// allows YYYY/M/D and periods instead of slashes | |
// http://stackoverflow.com/questions/24989065/trying-to-validate-yyyy-mm-dd | |
/^\d{4}[\/.]\d{1,2}[\/.]\d{1,2}$/ | |
// YYYY-MM-DD and YYYY-M-D | |
// http://stackoverflow.com/questions/6177975/how-to-validate-date-with-format-mm-dd-yyyy-in-javascript | |
/^\d{4}\-\d{1,2}\-\d{1,2}$/ | |
// YYYY-MM-DD | |
// https://gist.github.com/arth2o/8471150 | |
/(\d{4})-(\d{2})-(\d{2})/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment