I'm not sure exactly what you're trying to do but you can set the date/time to exactly what you want in a number of ways...
You can specify 12/25/2010 4:58 PM by using
DateTime myDate = Convert.ToDateTime("2010-12-25 16:58:00");
OR if you have an existing datetime construct , say 12/25/2010 (and any random time) and you want to set it to 12/25/2010 4:58 PM, you could do so like this:
DateTime myDate = ExistingTime.Date.AddHours(16).AddMinutes(58);
The ExistingTime.Date
will be 12/25 at midnight, and you just add hours and minutes to get it to the time you want.
you can't change the DateTime object, it's immutable. However, you can set it to a new value, for example:
var newDate = oldDate.Date + new TimeSpan(11, 30, 55);
It isn't possible as DateTime is immutable. The same discussion is available here: How to change time in datetime?
date = new DateTime(date.year, date.month, date.day, HH, MM, SS);
Source: Stackoverflow.com