Adding and subtracting numbers as time on user click


I have a course where a user needs to select some options and each have a time impact. 


I'd like to display the time in an hours, minutes format. 


I can easily count the time of each element so that its ends up at like 500 minutes, but who knows what 500 minutes is? (It's 8 hours btw)


I can't seem to figure out how to add the numbers in a time format so that it displays 1 hour rather than 60 minues, or 1 hour 30 minues rather than 90 minues etc etc.


Please help!

9 Replies
Lewis Masling

A user selects a check box, each check box is assocciated with  a text box that has description about a video that is XX in length.

Users do not need to select all the options, only those of interest. As they select they're options I'd like to display the accumulative amount of time that all selected videos will take to view (add deduct time if they unselect too) in hours and minutes.

So far I have a number variable called MM and am adding a set figure to that each time an option is selected, but it obviously counts past 60 and that's not what I want.

I'm not sure how to display it as 1 hour 0 minutes and so on rather than 0 hours 60 minutes etc.

 Does that help?


Julie Stelter

I have to go into a meeting. but I think this is a solution here

You need to add the checked boxes' time values in minutes to get a total and then divide by 60. This gives you the hours. Then subtract the multiple of 60 so if it is 2 hours you subtract 120 minutes from the total time. The remaining time is your minutes. I'll check back here later in the day to see if you need any more assistance. 

A screenshot and a list of variables you are using would be helpful for us to communicate. You can send it privately to me if you wish to

Gotta run!


Steve Gannon


Use two variables, one for hours, the other for minutes. Using triggers, when minutes gets to 60, add 1 to hours and reset minutes to 0. Create a custom state for the text box displaying the time to accommodate the time when minutes is less than 10. In that custom state, insert a leading 0 (so that 4:9 displays as 4:09). 

There are many, many timer examples in the forums to help get you started.

David Schwartz

Here's a solution using Javascript. I found the code here:

Essentially, I've just taken the variable "minutes", and used Javascript to populate a text variable that will show hours and minutes for the given number of minutes.


I've attached the SL file here with the Javascript.