JSFiddle - React, Tailwind, and code Playground

by frogggeee McFrogggeee

HTML

<!DOCTYPE html>
<html>
<head>
<body>
<h1>how much time have you looked at this website?</h1>
<p id = "time"></p>
<script>
let allTime = 0;
let milliseconds = 0;
let centiseconds = 0;
let deciseconds = 0;
let seconds = 0;
let minutes = 0;
let hours = 0;
let days = 0;
let months = 0;
let years = 0;
let decades = 0;
let centuries = 0;
let millenniums = 0;
function time() {
	deciseconds++;
  if (milliseconds > 9) {
  	milliseconds = 0;
    centiseconds++;
  } 
  if (centiseconds > 9) {
  	centiseconds = 0;
    deciseconds++;
  }
  if (deciseconds > 9) {
  	deciseconds = 0;
    seconds++;
  }
  if (seconds > 59) {
  	seconds = 0;
    minutes++;
  }
  if (minutes > 59) {
  	minutes = 0;
    hours++;
  }
  if (hours > 23) {
  	hours = 0;
    days++;
  }
  if (days > 364) {
  	days = 0;
    years++;
  }
  
  allTime = "you have looked at this website for "/* + milliseconds + " milliseconds and " + centiseconds + " centiseconds and "*/ + deciseconds + " deciseconds and " + seconds + " seconds and " + minutes + " minutes and " + hours + " hours and " + days + " days and "/* + months + " months and " */+ years + " years and " + decades + " decades and " + centuries + " centuries and " + millenniums + " millenniums.";
	document.getElementById("time").innerHTML = allTime;
}
setInterval(time, 100);
</script>
</body>
</head>
</html>