+ 1

How can i make an input numbers convert into hours, minutes and seconds?

for example: if i type : 124540 it should display hours = 34 minutes = 35 secinds = 40 thanks in advance

13th Jul 2017, 4:23 PM
Adrian Jason Rodas
Adrian Jason Rodas - avatar
5 Réponses
13th Jul 2017, 5:48 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 2
by using div. / and mod. %
13th Jul 2017, 4:47 PM
Dina
Dina - avatar
+ 1
Sami has the right answer, but here is how you think about this logically. Your input is in seconds. You need to find out how many hours that is by dividing by 3600 (or 60*60): hr = input / 3600; Now you have hours. The remainder of that division will be your minutes and seconds, so take the remainder of dividing by 3600: rem = input % 3600; And divide that by 60 to get minutes: min = rem / 60; The remainder of this is seconds: sec = rem % 60; I hope this helps
13th Jul 2017, 6:04 PM
Zeke Williams
Zeke Williams - avatar
0
yes
17th Nov 2024, 9:35 PM
elroy