none
DateTime.Now property value when IE is set with Thai language [th-TH]

    Question

  • I just noticed something with the DateTime.Now property. When I set the language on

    internet explorer to the Thai culture, I retrieve the property value as: 22/6/2554!

    When I look at the Year value by itself it gives me the correct year i.e. 2011, but the Now value

    is corrupted.

    When the language is set back to English the value is Ok. i.e. 6/22/2011.

    Can someone explain me if this is by design? Thanks!

    Wednesday, June 22, 2011 6:54 PM

Answers

  • According to this website, 2011 is year 2554 in the Thai calendar. If you set the computer's culture to th-TH, the string representation of the date is supposed to use the Thai calendar.
    • Marked as answer by eryang Monday, July 11, 2011 6:37 AM
    Wednesday, June 22, 2011 7:01 PM
  • The ToString method of the DateTime class uses the users culture to format the date. It uses the data in the CultureInfo.CurrentCulture and CurrentUICulture to do so.

    When you've chosen the Thai culture, it also uses the Thai culture settings for the Calendar. Not all countries around the world are using the 'western' calendar. The .NET framework supports all different calendars used around the world. You could even define your own calendar if you would want to. In your application, you should always use the UTC version of a DateTime value. And when displaying a value to a user, you should then convert it to the local culture/calendar settings.

    • Marked as answer by eryang Monday, July 11, 2011 6:37 AM
    Wednesday, June 29, 2011 4:05 PM

All replies

  • According to this website, 2011 is year 2554 in the Thai calendar. If you set the computer's culture to th-TH, the string representation of the date is supposed to use the Thai calendar.
    • Marked as answer by eryang Monday, July 11, 2011 6:37 AM
    Wednesday, June 22, 2011 7:01 PM
  • The ToString method of the DateTime class uses the users culture to format the date. It uses the data in the CultureInfo.CurrentCulture and CurrentUICulture to do so.

    When you've chosen the Thai culture, it also uses the Thai culture settings for the Calendar. Not all countries around the world are using the 'western' calendar. The .NET framework supports all different calendars used around the world. You could even define your own calendar if you would want to. In your application, you should always use the UTC version of a DateTime value. And when displaying a value to a user, you should then convert it to the local culture/calendar settings.

    • Marked as answer by eryang Monday, July 11, 2011 6:37 AM
    Wednesday, June 29, 2011 4:05 PM
  • See also: http://msdn.microsoft.com/en-us/library/system.globalization.calendar.aspx
    Wednesday, June 29, 2011 4:06 PM