Skip to content

Instantly share code, notes, and snippets.

@AlaeddineMessadi
Last active April 25, 2022 21:14
Show Gist options
  • Save AlaeddineMessadi/ded054e4a2c9151fac309462b21bd034 to your computer and use it in GitHub Desktop.
Save AlaeddineMessadi/ded054e4a2c9151fac309462b21bd034 to your computer and use it in GitHub Desktop.
Convert time From milliseconds to minutes in javascript
function timeCalc(millis) {
var minutes = Math.floor(millis / 60000)
var seconds = parseInt(((millis % 60000) / 1000).toFixed(0))
return minutes + ':' + (seconds < 10 ? '0' : '') + seconds
}
let start = new Date().getTime()
/** operation .... */
let end = new Date().getTime();
console.log(
'Execution time: ',
timeCalc(new Date(end - start))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment