How many secondes till 2AM ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How many secondes till 2AM ?

I try to calculate how many seconds there are left till 2AM. Using a timespan object at 1AM the result should be 3600 seconds at 3AM the result should be 82800 seconds at 10PM the result should be 14400 second How can I do this ?

12th Mar 2018, 8:38 PM
sneeze
sneeze - avatar
9 Answers
+ 2
from current time
12th Mar 2018, 8:46 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 2
with c# language
12th Mar 2018, 8:47 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
you mean hour to seconds
12th Mar 2018, 8:44 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
I mean calculate how many seconds are left till 2AM the next day ?
12th Mar 2018, 8:46 PM
sneeze
sneeze - avatar
+ 1
yes
12th Mar 2018, 8:47 PM
sneeze
sneeze - avatar
+ 1
yes
12th Mar 2018, 8:48 PM
sneeze
sneeze - avatar
+ 1
sorry C# is not my language but i hope you can get help from here😁 https://stackoverflow.com/questions/5733521/timespan-between-now-and-next-hour
12th Mar 2018, 8:50 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
That is almost what I was looking for except that 2AM is most of the time past midnight. Which makes it hard to substract datetime objects.
12th Mar 2018, 9:08 PM
sneeze
sneeze - avatar
0
Made some code based on your suggestion and another stackoverflow post https://stackoverflow.com/questions/4691721/how-to-find-the-exact-date-of-the-next-200-am-in-net/4691779 https://code.sololearn.com/celVg1TYs1nR I think I found a solution, thanks
12th Mar 2018, 9:48 PM
sneeze
sneeze - avatar