Return to Snippet

Revision: 48763
at July 8, 2011 20:31 by odavy


Initial Code
function secsTime(inSecs) {
 var timeStr = new String();
 var seconds = parseInt(inSecs);
 if (seconds < 0) {
   timeStr = "-";
   seconds *= -1;
 }
 var hours = parseInt(seconds/3600);
 var minutes = parseInt((seconds - (hours * 3600))/60);
 if (hours < 10) {
   if (hours == 0) {
     timeStr += "00:";
   } else {
     timeStr += "0" + hours + ":";
   }
 } else {
   timeStr += hours + ":";
 }
 if (minutes < 10) {
   if (minutes == 0) {
     timeStr += "00";
   } else {
     timeStr += "0" + minutes;
   }
 } else {
   timeStr += minutes;
 }
 return timeStr;
};

Initial URL

                                

Initial Description
Convert number of seconds to HH:MM

Initial Title
Javascript Secs to Time

Initial Tags
javascript, convert

Initial Language
JavaScript