Skip to content

Instantly share code, notes, and snippets.

@jdelStrother
Created June 30, 2015 07:30
Show Gist options
  • Select an option

  • Save jdelStrother/a2dfadfa9ee9ad6f54ee to your computer and use it in GitHub Desktop.

Select an option

Save jdelStrother/a2dfadfa9ee9ad6f54ee to your computer and use it in GitHub Desktop.
function secondsToHoursMinutesSeconds(totalSec) {
totalSec = Math.round(totalSec)
var hours = Math.floor(totalSec / 3600) % 24
totalSec -= hours * 3600
var minutes = Math.floor(totalSec / 60) % 60
totalSec -= minutes * 60
return padToTwo(hours) + ':' + padToTwo(minutes) + ':' + padToTwo(totalSec)
}
// 3000 -> "50:00"
function formatTime(time) {
var hours = Math.floor(time / 3600)
var minutes = Math.floor(time / 60) % 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment