|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Hi. I think i'm being a complete mathematical idiot, but how do you convert seconds (eg. 70) to minutes:seconds (1:10)? I'm drawing a complete blank!!! I've thought of dividing by 60 but what do you do with the remainder??
Can someone with a higher IQ than me please help? ![]() |
|
#2
|
||||
|
||||
|
70 modulo 60, which in javascript is written as
Code:
70 % 60
__________________
admin of Philosophorum - now well in its third year and still as modest as ever some character references universally acclaimed as "fundie of the worst kind" "the stubborn old loser whose high point of the day is making immature remarks and counting his rep points on an internet message board" stop bitching about lower case - it's my trademark™ |
|
#3
|
||||||
|
||||||
|
Quote:
To take a step further you could try this (i have not fully tested this): javascript Code:
|
|
#4
|
|||
|
|||
|
Quote:
I think you're going to need two variables: one to hold the minutes, the other to hold the seconds. For example, something like the following (haven't tested): Code:
secVar0 = 70; // The initial data, in seconds minVar = Math.floor(secVar0/60); // The minutes secVar = secVar0 % 60; // The balance of seconds You should now have the minutes and seconds for further use or output however you like. Regards, David |
![]() |
| Viewing: Dev Shed Forums > Web Design > JavaScript Development > Convert seconds to minutes:seconds |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|