Timespan between Now and Next Hour?
This seems to be the most simple:
3600 - DateTime.Now.TimeOfDay.TotalSeconds % 3600
(if you want it in whole numbers - integer - then prefix DateTime.Now...
with (int)
.
Just round the time of day in hours up to the next integral value:
var timeOfDay = DateTime.Now.TimeOfDay;
var nextFullHour = TimeSpan.FromHours(Math.Ceiling(timeOfDay.TotalHours));
var delta = (nextFullHour - timeOfDay).TotalSeconds;
//Completely misread. Completely re-writing
I woudl just do something Like this
int minutesToNextHour = 60 - DateTime.Now.Minutes;
int secondsToNextHour = minutesToNextHour * 60;