1 2 3 4 5 6 7
using System.Text.RegularExpressions; public bool Is24HourTime(string timevalue) { Regex regex = new Regex(@"^([01]?[0-9]|2[0-3]):[0-5][0-9]$"); return regex.IsMatch(timevalue.Trim()); }