--- example: title: Compare Time instructions: Find the number of minutes and seconds between `then` and `now` runtime: repl_js initial: js: |+2 const then = new Date() // or enter a time stamp for a not too distant date & time // const then = new Date("2019-12-02 12:24:00") setTimeout(() => { const now = new Date() console.log({then, now, diff: now - then}) }, 2123) solution: js: |+2 const then = new Date() // const then = new Date("2019-12-02 12:24:00") setTimeout(() => { const now = new Date() let seconds = Math.floor((now - then) / 1000) let minutes = 0 if (seconds >= 60) { minutes = Math.floor(seconds / 60) seconds = seconds - minutes * 60 } minutes = (minutes < 10 ? '0' : '') + minutes seconds = (seconds < 10 ? '0' : '') + seconds console.log({seconds, minutes}) }, 2123) css: ~ output: js4shiny::html_document_plain ---