Skip to content

Instantly share code, notes, and snippets.

@squalvj
Created April 15, 2020 04:25
Show Gist options
  • Save squalvj/4c586569f37f28ef50996233565e9320 to your computer and use it in GitHub Desktop.
Save squalvj/4c586569f37f28ef50996233565e9320 to your computer and use it in GitHub Desktop.
Minute, Second, Hour Calculation
const time = 3600 //second 1 hour
var minutes = Math.floor(time / 60);
//And to get the remaining seconds, multiply the full minutes with 60 and subtract from the total seconds:
var seconds = time - minutes * 60;
//Now if you also want to get the full hours too, divide the number of total seconds by 3600 (60 minutes/hour · 60 seconds/minute) first, then calculate the remaining seconds:
var hours = Math.floor(time / 3600);
time = time - hours * 3600;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment