convert time from seconds to HH:MM format





10
Date Submitted Fri. Aug. 18th, 2006 1:13 AM
Revision 1 of 1
Syntax Master sundaramkumar
Tags JavaScript
Comments 0 comments
This will convert the time from number of seconds to HH:MM format


function sec2hrsmins(Seconds,noUnits){ 
        lSeconds = Seconds

        lHrs = parseInt(lSeconds / 3600)
       
        lMinutes = (parseInt(lSeconds / 60)) - (lHrs * 60)

        if(lSeconds == 60){
                lMinutes = lMinutes + 1
                lSeconds = 0
        }

        if(lMinutes == 60){
            lMinutes = 0
            lHrs = lHrs + 1
        }
        tSeconds = lSeconds-( (lHrs * 60)+(lMinutes * 60) )
        if(noUnits)
                return (lHrs+":"+lMinutes)
        else
                return (lHrs+"H:"+lMinutes+"m")
}


 

Comments

There are currently no comments for this snippet.

Voting