If I have theses general sql valid dates in c# strings :
(each date can be in different order inside ) e.g. :
01 feb 2010
feb 01 2010
2010 01 feb
...
...
I want to convert a string date to DateTime
(c#). ( i want the ability to convert every format from above list)
while parse exact requires me 3!
combinations , is there any better solution ?
I think i got it ...
string[] str = new[] { "01 feb 2010","feb 01 2010","2010 01 feb","2010 feb 01","feb 2010 01" };
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
CultureInfo culture = CultureInfo.CreateSpecificCulture("en-US");
for (int i = 0; i < str.Length; i++)
{
DateTime t = DateTime.Parse(str[i], culture);
t.Dump();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With