I need the get a date object that specifies the next 2:00am that will come.
So pretend the time is 14:00 on the 15th, I need the date object to contain 2:00 on the 16th If the time is 1:00 on the 16th, I need the date object to contain 2:00 on the 16th
How do I do this?
In C#
DateTime dt = DateTime.Today.AddHours(2);
if (dt < DateTime.Now)
dt = dt.AddDays(1);
I'm sure there is a neater/cleverer way, but that will get the job done.
if the currenttime is before 2:00am, then the next 2:00am will be today else the next 2:00am will occur tomorrow (day + 1).
You will probably want to use a datetime object and increment the day by one, this should ensure that you are always on the correct date.
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