Posts Tagged ‘Globalization’


Posted: July 27, 2010 in C#, Globalization
Tags: ,

Saving date for specific culture …

System.IFormatProvider format = new System.Globalization.CultureInfo(“en-US”, true);
DateTime dt = DateTime.Parse(“Sun Feb 01 00:03:43 2009”, format);


DateTime dt = DateTime.ParseExact(“Fri Aug 01 09:03:43 2003”, “ddd MMM dd HH:mm:ss yyyy”, new System.Globalization.CultureInfo(“en-US”, true));

DateTime.Parse(“Sun Feb 01 00:03:43 2009”) will parse the date string based on the current user culture which will fail the conversion for some clutures. So it is good to save date with some specific culture.

ParseExact – parses to specified format.