Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DateTime day ending 24:00 (midnight)

Tags:

c#

.net

datetime

I have a customer that wants to see midnight represented as the end of the prior day.

Example

var date = DateTime.Parse("1/27/2010 0:00");
Console.WriteLine(date.ToString(<some format>));

Display:

1/26/2010 24:00

I believe this is valid in the ISO 8601 standard. (see this)

Is there any way to support this in .net (without an ugly string manipulation hack)?

like image 259
Mark Good Avatar asked Jan 27 '10 20:01

Mark Good


1 Answers

I guess you'll need a custom formatter for the dates. Look at the IFormatProvider and ICustomFormatter interfaces.

This and this may also help.

like image 87
Lucero Avatar answered Oct 11 '22 05:10

Lucero