Bug? DateTime.ToShortDateString() doesn't quite follow regional settings

  • Thread starter Thread starter Richard Thombs
  • Start date Start date
R

Richard Thombs

My regional settings show that my short date format is this:

dd/MM yy and correctly displays the example '16/6 04'

And yet DateTime.ToShortDateString returns '16/6 2004'

In other words it gives me a 4 digit year rather than a 2 digit year.
This seems to be echoed throughout all of the regional settings I've
tried and also happens on the full framework.

Is it actually possible to get a 2 year date out without having to
manually create it?

R.
 
Richard Thombs said:
My regional settings show that my short date format is this:

dd/MM yy and correctly displays the example '16/6 04'

And yet DateTime.ToShortDateString returns '16/6 2004'

In other words it gives me a 4 digit year rather than a 2 digit year.
This seems to be echoed throughout all of the regional settings I've
tried and also happens on the full framework.

Is it actually possible to get a 2 year date out without having to
manually create it?

R.

DateTime MyDate = new DateTime(2000, 1, 1, 0, 0, 0);
string MyString = MyDate.ToString("dd/MM yy");

http://msdn.microsoft.com/library/d...ide/html/cpconcustomdatetimeformatstrings.asp

Something like this yeah?
-a
 
I recently had a test pass fail on a similar problem! It turns out my
regional settings for short date were different than the test expected.
Check settings -> system -> regional settings to see whether the short date
format is what you're expecting...

Cheers,

Ryan Chapman
Software Development Engineer
..NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Ryan said:
I recently had a test pass fail on a similar problem! It turns out my
regional settings for short date were different than the test expected.
Check settings -> system -> regional settings to see whether the short date
format is what you're expecting...

Cheers,

Ryan Chapman
Software Development Engineer
.NET Compact Framework

This posting is provided "AS IS" with no warranties, and confers no rights.
My regional settings very clearly shows DD/MM YY.

To be clear, I am not using this format string directly, I am just using
the default functionality provided by DateTime.ToShortDateString() and
getting back what seems to be DD/MM YYYY instead.

R.
 
I'm sorry, I didn't read your first post clearly enough. I get the same
behavior--I'm investigating whether this is intended or a known issue.

Thanks,

Ryan

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top