Skip to content

Instantly share code, notes, and snippets.

@masautt
Last active September 16, 2019 04:47
Show Gist options
  • Save masautt/dc3b9ee9e9fe1b40f9ad1f53f4158006 to your computer and use it in GitHub Desktop.
Save masautt/dc3b9ee9e9fe1b40f9ad1f53f4158006 to your computer and use it in GitHub Desktop.
How to keep track of time elapsed in JavaScript?
let start = new Date();
setTimeout(()=> {
console.log((new Date() - start) / 1000 + " seconds have passed"); // --> 5 seconds have passed
},5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment