...

View Full Version : Transform minutes at hours



willjs
01-30-2006, 12:01 PM
Hi,

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

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

var mins = 80;
var hrs = mins/60;
alert(hrs);
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.

willjs
01-31-2006, 12: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? :(



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

glenngv
02-02-2006, 10: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum