View Full Version : Transform minutes at hours

01-30-2006, 01:01 PM

How can I do to transform minutes at hours with a javascript function? If somebody have an example to show me... :confused:

01-31-2006, 04:35 AM
Convert minutes to hours? Just divide the minutes to 60 and you get the hours.

var mins = 80;
var hrs = mins/60;
If you want to round off to N number of decimal places, use the toDecimal(N) (http://www.codingforums.com/showthread.php?p=178077#post178077) function that liorean wrote in JS FAQ in place of the buggy toFixed(N) method.

01-31-2006, 01:36 PM
Yes... I know, but I was not obtaining to transform in hh:mm format. Look this code. I made to transform, but how can I to return the value in ASP code? Do you know? :(

function converte_m2h(str){
result = str / 60;
h = Math.floor(result);
m = str - (h * 60);
if (m < 10){
m = "0" + m;
return h+":"+m;

02-02-2006, 11:48 AM
ASP is server-side, Javascript is client-side. Server-side code is executed first on the server producing HTML and Javascript output that then gets rendered and executed on the client browser. To pass data from client-side to server-side, you need to send HTTP request to the server via form submission, URL redirection or AJAX technique. Explain in detail what you want to accomplish and we'll tell you what the appropriate solution is.