I have the next simple code…
Console.WriteLine(default(DateTime).Date.ToString("U"));
The, emitted text is (I have an spanish language installation):
“lunes, 01 de enero de 0001 3:00:00”
Why it starts at 3 hours, instead of 0? it is a bug?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Well unless you’ve got a time machine or
DateTimeis really buggy, that’s not the output of the code you posted, which usesDateTime.Now.I suspect your code is really using
DateTime.MinValue(ornew DateTime()), and the reason that you’re seeing 3am is that (as per the documentation):So I suspect you’re in a time zone where midnight on January 1st 0001 local time is 3am UTC. (
DateTimeZone.MinValuehas a “kind” ofUnspecified, so will be treated as local when asked to convert to UTC.DateTimeis a bit of a mess around this area.)