Converting Seconds To dd:hh:mm:ss Format
Here is a simple function to write seconds in dd:hh:mm:ss:
- function sformat( s ) {
- var fm = [
- Math.floor(Math.floor(Math.floor(s/60)/60)/24)%24, //DAYS
- Math.floor(Math.floor(s/60)/60)%60, //HOURS
- Math.floor(s/60)%60, //MINUTES
- s%60 //SECONDS
- ];
- return $.map(fm,function(v,i) { return ( (v < 10) ? '0' : '' ) + v; }).join( ':' );
- }
Usage:
- var sf = sformat( 1450 ); //value of sf --> 00:00:24:10