DateTime > Date with optional time (ISO 8601) Favorite

Source: http://www.pelagodesign.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/

ISO 8601 Formatted Date with optional time.

Edited to remove most of the capturing sub groups. The 2 remaining are necessary for backreferences.

Sample Matches
Text Result
2009-12T12:34
Group #0
2009-12T12:34
Group #1
-
Group #2
:
match
2009
Group #0
2009
match
2009-05-19
Group #0
2009-05-19
Group #1
-
match
2009-05-19
Group #0
2009-05-19
Group #1
-
match
20090519
Group #0
20090519
Group #1
match
2009123
Group #0
2009123
Group #1
match
2009-05
Group #0
2009-05
Group #1
-
match
2009-123
Group #0
2009-123
Group #1
-
match
2009-222
Group #0
2009-222
Group #1
-
match
2009-001
Group #0
2009-001
Group #1
-
match
2009-W01-1
Group #0
2009-W01-1
Group #1
-
match
2009-W51-1
Group #0
2009-W51-1
Group #1
-
match
2009-W511
Group #0
2009-W511
Group #1
-
match
2009-W33
Group #0
2009-W33
Group #1
-
match
2009W511
Group #0
2009W511
Group #1
match
2009-05-19
Group #0
2009-05-19
Group #1
-
match
2009-05-19 00:00
Group #0
2009-05-19 00:00
Group #1
-
Group #2
:
match
2009-05-19 14
Group #0
2009-05-19 14
Group #1
-
match
2009-05-19 14:31
Group #0
2009-05-19 14:31
Group #1
-
Group #2
:
match
2009-05-19 14:39:22
Group #0
2009-05-19 14:39:22
Group #1
-
Group #2
:
match
2009-05-19T14:39Z
Group #0
2009-05-19T14:39Z
Group #1
-
Group #2
:
match
2009-W21-2
Group #0
2009-W21-2
Group #1
-
match
2009-W21-2T01:22
Group #0
2009-W21-2T01:22
Group #1
-
Group #2
:
match
2009-139
Group #0
2009-139
Group #1
-
match
2009-05-19 14:39:22-06:00
Group #0
2009-05-19 14:39:22-06:00
Group #1
-
Group #2
:
match
2009-05-19 14:39:22+0600
Group #0
2009-05-19 14:39:22+0600
Group #1
-
Group #2
:
match
2009-05-19 14:39:22-01
Group #0
2009-05-19 14:39:22-01
Group #1
-
Group #2
:
match
20090621T0545Z
Group #0
20090621T0545Z
Group #1
Group #2
match
2007-04-06T00:00
Group #0
2007-04-06T00:00
Group #1
-
Group #2
:
match
2007-04-05T24:00
Group #0
2007-04-05T24:00
Group #1
-
match
2010-02-18T16:23:48.5
Group #0
2010-02-18T16:23:48.5
Group #1
-
Group #2
:
match
2010-02-18T16:23:48,444
Group #0
2010-02-18T16:23:48,444
Group #1
-
Group #2
:
match
2010-02-18T16:23:48,3-06:00
Group #0
2010-02-18T16:23:48,3-06:00
Group #1
-
Group #2
:
match
2010-02-18T16:23.4
Group #0
2010-02-18T16:23.4
Group #1
-
Group #2
:
match
2010-02-18T16:23,25
Group #0
2010-02-18T16:23,25
Group #1
-
Group #2
:
match
2010-02-18T16:23.33+0600
Group #0
2010-02-18T16:23.33+0600
Group #1
-
Group #2
:
match
2010-02-18T16.23334444
Group #0
2010-02-18T16.23334444
Group #1
-
match
2010-02-18T16,2283
Group #0
2010-02-18T16,2283
Group #1
-
match
2009-05-19 143922.500
Group #0
2009-05-19 143922.500
Group #1
-
Group #2
match
2009-05-19 1439,55
Group #0
2009-05-19 1439,55
Group #1
-
Group #2
match
200905no match
2009367no match
2009-no match
2007-04-05T24:50no match
2009-000no match
2009-M511no match
2009M511no match
2009-05-19T14a39rno match
2009-05-19T14:3924no match
2009-0519no match
2009-05-1914:39no match
2009-05-19 14:no match
2009-05-19r14:39no match
2009-05-19 14a39a22no match
200912-01no match
2009-05-19 14:39:22+06a00no match
2009-05-19 146922.500no match
2010-02-18T16.5:23.35:48no match
2010-02-18T16:23.35:48no match
2010-02-18T16:23.35:48.45no match
2009-05-19 14.5.44no match
2010-02-18T16:23.33.600no match
2010-02-18T16,25:23:48,444no match