Convert time to Am and Pm format

For converting the selected time to am and pm format. First take a time for example 04:54:22. Then write this below method in your coding page.


public string converttime(string sp)
{
string s = DateTime.ParseExact(sp.Substring(0, 5), "HH:mm", CultureInfo.CurrentCulture).ToString("hh:mm tt");
return s;
}


Then call this method where your need.



String ss=”04:54:22”;
converttime(ss);

Post a Comment

0 Comments