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

Please support RegExLib Sponsors

Sponsors

Regular Expression Details

Title Test Find Pattern Title
Expression
^ *(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M) *$
Description
validate 12-hour time with am/pm after it, with optional spaces before or after, and optionally between time and am/pm.
Matches
12:00am | 1:00 PM | 12:59 pm
Non-Matches
0:00 | 0:01 am | 13:00 pm
Author Rating: Not yet rated. Jim Tebbel
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: A liitle modification
Name: RapidMod.com
Date: 2/19/2015 8:50:53 PM
Comment:
I needed a little modification for my specific use but thank you $pattern = "%(1[0-2]|[1-9]):[0-5][0-9] *(a|p|A|P)(m|M)%"; preg_match($pattern, trim($time),$data);


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