The following JavaScript code helps to get the time difference between two date times.
- <html>
- <body>
- <canvas id="newCanvas" width="150" height="100"
- style="border:1px solid green;"></canvas>
- <script type="text/javascript">
-
- var d1 = new Date();
-
- var canvas = document.getElementById("newCanvas");
- var context = canvas.getContext("2d");
- context.fillStyle = "green";
- context.fillRect(0,0,100,60);
-
- var d2 = new Date();
-
- document.write("Your Operation took " + (d2.getTime() - d1.getTime()) + " milliseconds");
- </script>
- </body>
- </html>
Thank you, keep learning and sharing.