Skip to content

Instantly share code, notes, and snippets.

@perliedman
Created October 27, 2016 12:20
Show Gist options
  • Select an option

  • Save perliedman/11a4c2a8395e1abd8653d66dee44d835 to your computer and use it in GitHub Desktop.

Select an option

Save perliedman/11a4c2a8395e1abd8653d66dee44d835 to your computer and use it in GitHub Desktop.

Revisions

  1. perliedman created this gist Oct 27, 2016.
    13 changes: 13 additions & 0 deletions secondsToTime.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    var secondsToTime = function(s) {
    var pad = function(v) {
    return v < 10 ? '0' + v : v.toString();
    }

    var result = '';
    for (var i = 0; i < 3; i++) {
    result = pad(s % 60) + (i ? ':' : '') + result;
    s = Math.floor(s / 60);
    }

    return result;
    }