Regular Expression to validate the Time Format in Javascript

You want to validate times in various traditional time formats, such as hh:mm and hh:mm:ss in both 12-hour and 24-hour formats.

Hours and minutes, 12-hour clock:


Hours and minutes, 24-hour clock:


Hours, minutes, and seconds, 12-hour clock:


Hours, minutes, and seconds, 24-hour clock:


Hours, minutes, 12-hours clock:

^(0?[1-9]|1[012]):[0-5][0-9] ([ap]m)$


Was this post helpful?
Let us know if you liked the post. That’s the only way we can improve.
Harinder Singh

Harinder Singh

My name is Harinder Singh and I specialize in Software industry. I consider myself as a life learner. I love learning new concepts, embracing new ideas and reading and searching for innovation.