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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Date and time validation
Expression
^((((0?[1-9]|1[012])/(0?[1-9]|1\d|2[0-8])|(0?[13456789]|1[012])/(29|30)|(0?[13578]|1[02])/31)/(19|[2-9]\d)\d{2}|0?2/29/((19|[2-9]\d)(0[48]|[2468][048]|[13579][26])|(([2468][048]|[3579][26])00))))[\s]((([0]?[1-9]|1[0-2])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?( )?(AM|am|aM|Am|PM|pm|pM|Pm))|(([0]?[0-9]|1[0-9]|2[0-3])(:|\.)[0-5][0-9]((:|\.)[0-5][0-9])?))$
Description
The date field takes all values with slashes. Leap year is taken care of Year has to be specified in 4digit. Time is a 12hrclock taking am n pm(case insensitive). AM or Pm has to be specified. Not suited for 24hr clock. In the format of SQL Server datetime field
Matches
09/10/2004 10:30am, 1/1/1999 1:32pm
Non-Matches
09/02/07,02/29/2001,23:00
Author Rating: The rating for this expression. Prem
Source credit passed on to other regex users
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: Require AM/PM
Name: Dan
Date: 3/30/2018 1:00:08 AM
Comment:
Hey fam - how can we make am/pm required?


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