I’m trying to figure an hour interval from a start time…
So if I allow the user to choose a value between 1 and 12 I want to figure out what times that represent in a 24 hour clock.
Lets say it is 9:00AM and they want to be notified every 4 hours during that day. I would need it to have the following values:
9AM
1PM
5PM
9PM
I’m trying to use the % (modulus) but I’m not getting what I’m expecting(4 % 24)… Any ideas?
DateTimerepresenting the current time (9:00 AM)TimeSpanrepresenting the time interval (4 hours)DateTime.Add(TimeSpan)method to produce the time of the next notificationThe 12/24 hour clock does not play into it at all: you can format the next time the way you or your user wish – as a 24-hour clock using the
"HH:mm"mask or as a 12-hour clock using"hh:mm"mask.