| Title |
Test
Find
YYYY-MM-DD HH:MM:SS
|
| Expression |
^([0-9]{4})-([0-1][0-9])-([0-3][0-9])\s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$ |
| Description |
SQL datetime format tester YYYY-MM-DD HH:MM:SS |
| Matches |
2007-07-01 01:01:01 | 2007-08-04 18:01:01 |
| Non-Matches |
2007-07-01 | 2007/07/01 | 2007-08-04 24:00:00 | 2007/07/01 12:12 |
| Author |
Rating:
Fehér Zsolt
|
| Source |
^([0-9]{4})-([0-1][0-9])-([0-3][0-9])\s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$ |
| Your Rating |
|
Title: Date regex is wrong
Name: Sam
Date: 6/3/2020 4:36:00 AM
Comment:
works for 2007-19-39 12:12:12
Title: Date regex is wrong
Name: Sam
Date: 6/3/2020 4:35:28 AM
Comment:
works for 2007-19-39 12:12:12
Title: SLIGHTLY better
Name: TESTiculER
Date: 9/22/2011 7:16:08 AM
Comment:
This will not allow > 31 for dd, but WILL still allow February 30th. You could do a look behind for the day and year too, to check for month length/leap year, but its probably not worth it.
^([0-9]{4})-([0-1][0-9])-([0-3]((?<!3)[0-9]|[0-1]))\s([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$
Title: June 34th?
Name: TESTiculER
Date: 9/22/2011 7:00:42 AM
Comment:
Careful, his will allow 2007-07-34 01:01:01. The 34th day of June. Need a lookbehind for whether the first digit of a day is a three. Also, allows February 31.
Good enough for testing basic shape though.