Skip to content

Instantly share code, notes, and snippets.

@Chavao
Created March 4, 2012 17:54
Show Gist options
  • Save Chavao/1974142 to your computer and use it in GitHub Desktop.
Save Chavao/1974142 to your computer and use it in GitHub Desktop.
Dado um valor em segundos, a função monta um contador no formato HH:MM:SS
function mountCounter(p_seconds)
{
var hours = new String(parseInt(parseInt(p_seconds) / 3600));
var minutes = new String(parseInt((p_seconds / 60) % 60));
var seconds = new String(parseInt(p_seconds % 60));
if(hours.length == 1) hours = '0' + hours;
if(minutes.length == 1) minutes = '0' + minutes;
if(seconds.length == 1) seconds = '0' + seconds;
return hours + ':' + minutes + ':' + seconds;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment