I have a variable which is defined as a DateTime
. I need to assign it today's date but have the time be 4 PM. How do I do this?
C# today's date Now; Console. WriteLine(now. ToString("F")); The example prints today's date.
The value of this constant is equivalent to 00:00:00.0000000 UTC, January 1, 0001, in the Gregorian calendar. MinValue defines the date and time that is assigned to an uninitialized DateTime variable. The following example illustrates this. C# Copy.
You want DateTime.Today.AddHours(16)
DateTime.Today
will return today's date at midnight.
You can also use the Date
property to drop the time from an arbitrary DateTime
value.
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