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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find DateTime
Expression
^([0]\d|[1][0-2]\/([0-2]\d|[3][0-1])\/([2][0]\d{2})\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d)?\s(AM|am|aM|Am|PM|pm|pM|Pm)
Description
Date Time with am/pm.
Matches
10/13/2008 12:00:00 AM, 10/13/2008 12:00:00 PM
Non-Matches
10/13/2008 12:00:00
Author Rating: The rating for this expression. Yaron
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

Title: Question Mark might be out of place?
Name: JohnCannon.IT
Date: 12/12/2014 10:28:32 AM
Comment:
It looks like the open parenthesis at the second character and the close parenthesis just before the ? are paired. Based on that, doesn't it mean everything before the AM/PM stuff is optional? I think if you modify if as below, it makes all the time optional, and still allows the date: ^[0]\d|[1][0-2]\/([0-2]\d|[3][0-1])\/([2][0]\d{2})(\s([0-1]\d|[2][0-3])\:[0-5]\d\:[0-5]\d\s(AM|am|aM|Am|PM|pm|pM|Pm))? There are probably better ways to do this.


Title: Allows invalid date
Name: Michael Ash
Date: 12/8/2008 11:15:34 AM
Comment:
Allows invalid date values like 00/00/2000


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