Calling ToString("YYYY-mm-dd") results in wrong date format
c#, string-formatting
Solution
Year must be lowercase and month uppercase:
Date = date.ToString("yyyy-MM-dd"); // btw, lowercase mm means minutes
Custom Date and Time Format Strings
Problem
I've got a constructor which takes a `DateTime` object: ``` public Report(DateTime date, string start = "0", string end = "0") { Logger.Info("Creating a new Report..."); StartTime = start; EndTime = end; Date = date.ToString("YYYY-mm-dd"); SetStartEndTimes(); Logger.Info("Report Created"); } ``` Now, this was working fine just 3 days ago. However, I come back today, after a break, and this is the results I'm seeing: As you can see, the date being passed in is right. However, after the format, it is not. Again, this worked before my break. I come back, and I get this. Am I missing something? Why would it format so incorrectly after working since the beginning? EDIT Thanks guys. The messed up part is looking through the source control at previous versions, this worked. Or maybe I imagined it working. I don't know. But it's been this way for about 3 months.