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.
To do this, you use the "MM/yyyy" format string. The format string uses the current culture's date separator. Getting a string that contains the date and time in a specific format. For example, the "MM/dd/yyyyHH:mm" format string displays the date and time string in a fixed format such as "19//03//2013 18:06".
DateTimeFormat. ShortDatePattern = "MM/dd/yyyy"; app.
The "fff" custom format specifier represents the three most significant digits of the seconds fraction; that is, it represents the milliseconds in a date and time value.
Year must be lowercase and month uppercase:
Date = date.ToString("yyyy-MM-dd"); // btw, lowercase mm means minutes
Custom Date and Time Format Strings
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With