Parsing a DateTime String into Custom Date and Time Format String
- by AMissico
With .NET, I have "Thursday, April 10, 2008 1:30:00 PM" and I want "dddd, dd MMMM, yyyy h:m:s t", "6:09:01 PM" and want ""hh:mm:ss tt", "Fri 29 Aug" and want "ddd d MMM", and so on. It seems I should be able to use DateTimeFormatInfo in some way.
I figured I can format the date with each pattern returned by GetAllDateTimePatterns, and when the original date string and the formated date string match then I have the format. Yet, I want to generate custom formats, not the standard formats.
I want the format string. I do not want the date. I have both the DateTime value and the formatted string value for the date. I need <formatString> as in ToString(<formatString>).