JSFiddle - React, Tailwind, and code Playground
by damphat
HTML
<body>
<div id="txt">click START then STOP to calculate delta time</div>
<button id="start">START</button>
<button id="stop">STOP</button>
<div style="background-color:yellow">NOTE: if you change system clock during start-stop, Delta will be wrong</div>
</body>
JavaScript
$(document).ready(function () {
var start_time;
$("#start").click(function () {
start_time = Date.now();
$("#txt").text("Start time = " + start_time);
})
$("#stop").click(function () {
var stop_time = Date.now();
var delta_time = stop_time - start_time;
$("#txt").text("Delta = " + delta_time + " miliseconds");
})
})