using
System.Text.RegularExpressions;
string strcd = DateTime.Now.ToString("hh:mm:ss
tt"); //02:56:59 PM
bool isOK = Regex.IsMatch(strcd, @"[0-2][0-9]\:[0-5][0-9]\:[0-5][0-9]\
[aApP][mM]");
if (isOK)
{
// Do something.
}
else
{
string strcd =
DateTime.Now.ToString("hh:mm tt");
//01:06 PM
bool isOK = Regex.IsMatch(strcd, @"[0-2][0-9]\:[0-5][0-9]\ [aApP][mM]");
if (isOK)
{
// Do something.
}
else
{
// Do something
else.
}