Skip to content

Instantly share code, notes, and snippets.

@netsi1964
Created September 12, 2017 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netsi1964/96a064284075d201e2f2722f157cf70a to your computer and use it in GitHub Desktop.
Save netsi1964/96a064284075d201e2f2722f157cf70a to your computer and use it in GitHub Desktop.
Convert a youtube time to visual hh:mm:ss
Object.prototype.toTimeString = function() {
var t = parseFloat(this);
var hou = (parseInt(t / 3600) % 24).toString().padStart(2, "0"),
min = (parseInt(t / 60) % 60).toString().padStart(2, "0"),
sec = parseInt(t % 60)
.toString()
.padStart(2, "0");
return `${hou}:${min}:${sec}`;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment