0

Even though i have

<globalization uiCulture="en" culture="en-GB" requestEncoding="utf-8" />

in web.config DateTime.TryParse, without passing CultureInfo, is ignoring my current Culture .

Application is a C# MVC3 web application.

Is there any solution for this.

Rafi
  • 57
  • 1
  • 8
  • 1
    MSDN says that TryParse should use current culture info. Can you give us an example of incorrect parsing? Also you can use TryParseExact - http://msdn.microsoft.com/en-gb/library/system.datetime.tryparseexact.aspx , if it can be a solution for you. – Smileek May 17 '12 at 08:23
  • Now I understand, that the web.config for the MVC application is not applied, to the child aspx web application. Once I modified the web.config in the aspx application folder it works fine. Thank you for the replies. – Rafi May 17 '12 at 08:42

1 Answers1

0

@Smileek right, but you always can try something like this

DateTime dateResult;
dateString = "03/01/2009 10:00 AM";
culture = CultureInfo.CreateSpecificCulture("en-US");
styles = DateTimeStyles.None;
DateTime.TryParse(dateString, culture, styles, out dateResult);
Likurg
  • 2,742
  • 17
  • 22