I have two javascript vars (they're coming from text boxes, so they're probably being evaluated as strings) in this format: 02:30 and 4:45
they represent hours and minutes.
I want to add them together to get 07:15 but I can't figure it out.
I have two javascript vars (they're coming from text boxes, so they're probably being evaluated as strings) in this format: 02:30 and 4:45
they represent hours and minutes.
I want to add them together to get 07:15 but I can't figure it out.
Split on the colon. Sum the minutes. Divide by 60 and round to get hours and modulo to get minutes. Add the hours to the other total hours. Cast the integers as strings and concatenate to get the new time.
I've started working with Date.js (http://www.datejs.com/) and have found it to make things like this a lot easier.