Problem with DateTime.Parse

T

Tobias Olbort

Hello,

why does this not work (the OS runs with german settings):

DateTimeFormatInfo dtFI = new DateTimeFormatInfo();

dtFI.FullDateTimePattern = "ddd MMM dd HH:mm:ss yyyy";
dtFI.AbbreviatedDayNames = new string[] {"Mon", "Tue", "Wed",
"Thu", "Fri", "Sat", "Sun"};
dtFI.AbbreviatedMonthNames = new string[] {"Jan", "Feb", "Mar",
"Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", ""};
return DateTime.Parse("Fri Aug 01 09:03:43 2003", dtFI);

Thanks for any suggestion.

Tobias
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hello Tobias,

Try a simpler solution:

System.IFormatProvider format =
new System.Globalization.CultureInfo("en-US", true);

return DateTime.Parse("Fri Aug 01 09:03:43 2003", format);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top