In this article I will show how the use of culture in the web.config file does not work as expected with the format of the date and other information.
Before starting, it is important to explain about the CultureInfo class. The CultureInfo Class Provides information about a specific culture. The information includes the names for the culture, the writing system, the calendar used, the sort order of strings, and formatting for dates and numbers.
How to use
You should be parsing the string to a DateTime and then format it to the second format using ToString() method. Example in C#:
DateTime dt2 = DateTime.ParseExact(date31strin, “MM-dd-yyyy HH:mm:ss”, CultureInfo.InvariantCulture);
string secondFormat = dt2.ToString(“Second format string”);
And that’s it! This will ensure you do not have problems when you work with date formats in your ASP applications.
This concludes Date format in ASP.Net