Skip to content

Instantly share code, notes, and snippets.

@stevenkuipers
Last active October 31, 2018 13:13
Show Gist options
  • Save stevenkuipers/6b87ee79b8bda41379151ce1a874dbf3 to your computer and use it in GitHub Desktop.
Save stevenkuipers/6b87ee79b8bda41379151ce1a874dbf3 to your computer and use it in GitHub Desktop.
Time string format
// @Param integer - Takes an integer as input
// integer from parameter n, where n represents number of seconds
// Returns a string in the format HH:MM:SS
// @Return string
// from this SO post https://stackoverflow.com/a/25279399/7384523
function createTimeString(n){
var date = new Date(null);
date.setSeconds(n); // specify value for SECONDS here
var timeString = date.toISOString().substr(11, 8);
return timeString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment