I have a string containing information 08/23/2016~08:00 - 12:00~D
. I want to first convert it into date i.e 08/23/2016
and then convert this into Tuesday,August 23,2016
. Is it possible to convert it in this format?
A combination of string
- and DateTime
-methods
string input = "08/23/2016~08:00 - 12:00~D";
string datePart = input.Split('~')[0].Trim();
DateTime dt;
if (DateTime.TryParse(datePart, DateTimeFormatInfo.InvariantInfo, DateTimeStyles.None, out dt))
{
string output = dt.ToString("dddd,MMMM dd,yyyy", DateTimeFormatInfo.InvariantInfo);
}