Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to create a Midnight DateTime in C#

Tags:

c#

datetime

I need to create a midnight DateTime

I've just done this:

DateTime endTime = DateTime.Now; endTime.Subtract(endTime.TimeOfDay); 

Haven't test it yet, I'm assuming it works but is there a better/cleaner way?

like image 951
endian Avatar asked Oct 29 '08 09:10

endian


1 Answers

Just use foo.Date, or DateTime.Today for today's date

like image 103
Marc Gravell Avatar answered Sep 24 '22 09:09

Marc Gravell