Last active
April 25, 2022 21:14
-
-
Save AlaeddineMessadi/ded054e4a2c9151fac309462b21bd034 to your computer and use it in GitHub Desktop.
Convert time From milliseconds to minutes in javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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