RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find DateTime
Expression
^(0?[1-9]|[12][0-9]|3[01])[- /.](0?[1-9]|1[012])[- /.](19|20)?[0-9]{2}? ?((([0-1]?\d)|(2[0-3])):[0-5]\d)?(:[0-5]\d)? ?([a,p,A,P][m,M])?$
Description
Regex to match date and or time either in 12 or 24 hour format. It will also allow for am/pm with mixed cases.
Matches
31-12-2010 14:15:22 | 1.1.2010 00:00:00 | 2/1/2010 | 31/1/2011 05:22 pm
Non-Matches
1.31.2011 | 31.1.2011 1455 | 31.1.2011 14 pm
Author Rating: Not yet rated. Ralf Koch
Source
Your Rating
Bad Good

Enter New Comment

Title

Name

Comment

Spammers suck - we apologize. Please enter the text shown below to enable your comment (not case sensitive - try as many times as you need to if the first ones are too hard):

Existing User Comments

Copyright © 2001-2025, RegexAdvice.com | ASP.NET Tutorials