my input will be from a variable (Ticket.CreationDate) and will look like
2/4/2011 9:34:48 AM (it will vary of course)
Ideally I could pass in the variable as-i
Create a function which takes date and in-format string and out-format string as parameter
string FormatDate(string date, string informat,string outformat)
{
var culture = CultureInfo.CreateSpecificCulture("en-US");
return DateTime.ParseExact(date, informat, culture).ToString(outformat);
}
FormatDate("2/4/2011 9:34:48 AM","M/d/yyyy H:m:s tt","H:m:s") //9:34:48
You can get different format string from here