DoctorGonzo
Programmer
Hi guys,
Tsuji and Diancecht gladly provided me with the code below last week which converts MINUTEs into HOURS and MINUTES in the format hh:mm.... this works perfectly.
EXAMPLE :
function toHoursAndMinutes(minutes) {
var mins = minutes%60; //modulus dividing by 60
var hrs = (minutes - mins)/60; //Now you get an integer division
alert(hrs+":"+mins);
}
Brilliant. However, I now have a requirement to do the OPPOSITE of this - ie
1) get a handle to a field where user has entered hh:mm
2) convert this to minutes
i.e. user enters 2:15 and this converts to 135 minutes
probably need to validate to make sure user enters correctly in hh:mm format
can anyone assist? This maths/logic is a big problem for me
Many thanks!
Gonzo
Tsuji and Diancecht gladly provided me with the code below last week which converts MINUTEs into HOURS and MINUTES in the format hh:mm.... this works perfectly.
EXAMPLE :
function toHoursAndMinutes(minutes) {
var mins = minutes%60; //modulus dividing by 60
var hrs = (minutes - mins)/60; //Now you get an integer division
alert(hrs+":"+mins);
}
Brilliant. However, I now have a requirement to do the OPPOSITE of this - ie
1) get a handle to a field where user has entered hh:mm
2) convert this to minutes
i.e. user enters 2:15 and this converts to 135 minutes
probably need to validate to make sure user enters correctly in hh:mm format
can anyone assist? This maths/logic is a big problem for me
Many thanks!
Gonzo