I have a time that is 16:23:01. I tried using DateTime.ParseExact
, but it\'s not working.
Here is my code:
string Time = \"16:23:01\";
Date
This gives you the needed results:
string time = "16:23:01";
var result = Convert.ToDateTime(time);
string test = result.ToString("hh:mm:ss tt", CultureInfo.CurrentCulture);
//This gives you "04:23:01 PM" string
You could also use CultureInfo.CreateSpecificCulture("en-US")
as not all cultures will display AM/PM.