Skip to content

Instantly share code, notes, and snippets.

@elhardoum
Last active December 14, 2018 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elhardoum/ee82494a1e0c0d0fdf0c3cc098eceffd to your computer and use it in GitHub Desktop.
Save elhardoum/ee82494a1e0c0d0fdf0c3cc098eceffd to your computer and use it in GitHub Desktop.
var start = +new Date, d, chrono
setInterval(function()
{
d = new Date( +new Date - start )
chrono = (''+d).match( /\d+:\d+(?= )/g )[0] + ':' + Math.floor(d.getMilliseconds()/100)
document.body.innerHTML = chrono.replace(/(\d+)/g, '<span>$1</span>').replace(':', '\'').replace(':', '"')
}, 100)
var start = +new Date, d
setInterval(e => {
d = new Date( +new Date - start )
document.body.innerHTML = ''
+ '<span>' + d.getMinutes() + '</span>\'' // minutes
+ '<span>' + ( d.getSeconds() < 10 ? '0' : '' ) + d.getSeconds() + '</span>"' // seconds
+ '<span>' + Math.floor(d.getMilliseconds()/100) + '</span>' // milliseconds
}, 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment