Reputation: 1358
I converted my VS 2008 project into vs 2010 but kept it on .NET 3.5 framework. I don't set my locale anywhere within the app.
I've got a couple on computers running windows 7 and XP and both have the region set to EN-AU.
Sometime my app returns the short date format like MM/dd/YY (EN-US). As soon as you quit it and start again it reverts to the proper format for AU(dd/mm/yy). Again I'm not setting my locale anywhere in the project. (I have some RDLC reports which have EN-US as the language though)
Any reason why this would be happening? I tried setting the Thread locale explicitly as well. But same behaviour.
Upvotes: 1
Views: 566
Reputation: 18662
This is strange. I would advice you not to use ToShortDate() as I have seen couple of issues from it. Instead, I recommend using following code:
string formattedDate = someDateTime.ToString("d", CultureInfo.CurrentCulture);
This basically does the same. And you can introduce constant instead of "d" for greater readability (it is short date formatting string).
It is always good practice to pass IFormatProvider, as it works as a comment clearly documenting your assumptions (in the example above I said: this is the date string I want to present to user; if I wanted to use this date for further processing, send it via network, etc. I would use CultureInfo.InvariantCulture).
Upvotes: 1
Reputation: 4179
Datetime.UTC is based on local system time and whether the local system is observing daylight savings time.
Regardless whether you set your location. The datetime picker should automatically set itself based on UTC and your system.
Check out this link which gives some helpful hints to datetime
http://social.msdn.microsoft.com/forums/en-US/netfxbcl/thread/6b3b1e95-e044-46db-94ba-0e75fcf9d2b2/
Upvotes: 3