Reputation: 1259
I want a DateTime variable which is today (any given time of the day) at 23:00.
There has simply got to be a cleaner way to do this because this reminds me too much of good ol' ASP.Classic...
var startDate = DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:00:00");
Anyone?
Upvotes: 3
Views: 503
Reputation: 10681
A clean Way is:
DateTime myTime = DateTime.Now.Date.AddHours(23);
Another Way is:
DateTime myTime = DateTime.Now.Date + new TimeSpan("23","0","0");
Upvotes: 0