.net - C# convert Datetime to Thursday, 26th July 2014 format -
.net - C# convert Datetime to Thursday, 26th July 2014 format -
i want convert datetime variable next format: "thursday, 26th july 2014".
what right approach.
thanks
i think need separate parts before , behind th
each other:
datetime dt = new datetime(2014, 07, 26); string result = string.format("{1}{0} {2}", dt.day == 1 ? "st" : dt.day == 2 ? "nd" : dt.day == 3 ? "rd" : "th", dt.tostring("dddd, dd", cultureinfo.invariantculture), dt.tostring("mmmm yyyy", cultureinfo.invariantculture));
if don't need exact format can utilize datetime
methods tolongdatestring
uses current civilization , has fixed format.
.net datetime formatting
Comments
Post a Comment