Parsing a DateTime String into Custom Date and Time Format String
Posted
by AMissico
on Stack Overflow
See other posts from Stack Overflow
or by AMissico
Published on 2009-10-01T17:45:24Z
Indexed on
2010/06/12
1:42 UTC
Read the original article
Hit count: 374
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>)
.
© Stack Overflow or respective owner