Given the following C# code:
var dt = DateTime.Now;
Console.WriteLine("{0:MM/dd/yy} ... {1}", dt, string.Format("{0:MM/dd/yy}", dt));
... when the short date (under Windows 7, Control Panel -> Region and Language -> Additonal Settings -> Date
) is set to the USA standard of "M/d/yyyy
," I get this:
06/17/14 ... 06/17/14
However, when I change the short date to "ddd dd MMM yyyy
," I get this:
06/17/14 ... 06 17 14
I was under the impression that Console.WriteLine
and string.Format
always string formatted DateTime
values identically. What is the explanation for this discrepancy?
EDIT: Looks like this happens only in standard unit test output (Visual Studio), which is where I originally saw the problem. When the code executes in a console app, the output is 06 17 14 ... 06 17 14
.