Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2005
    Location
    São Paulo, Brasil
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Transform minutes at hours

    Hi,

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

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    Convert minutes to hours? Just divide the minutes to 60 and you get the hours.
    Code:
    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) function that liorean wrote in JS FAQ in place of the buggy toFixed(N) method.

  • #3
    New Coder
    Join Date
    Dec 2005
    Location
    São Paulo, Brasil
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

    Code:
    <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>
    Tks
    William

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    10,966
    Thanks
    0
    Thanked 236 Times in 233 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •