JSFiddle - React, Tailwind, and code Playground

by Kalu Singh Rao

HTML

<div id="box"></div>

JavaScript

$(function () {
            fadeout();
        });

        function fadein() {
            UpdateTime();
            $("#box").fadeIn("500", fadeout);
        }
        function fadeout() {
            $("#box").fadeOut("500", fadein);
        }

        function GetTime() {
            var now = new Date();
            var obj = {
                Hour: now.getHours(),
                Minute: now.getMinutes(),
                Second: now.getSeconds()
            };

            return obj;
        }

        function UpdateTime() {
            var box = $("#box");

            var obj = GetTime();
            if (obj.Hour < 10)
                obj.Hour = "0" + obj.Hour;
            if (obj.Minute < 10)
                obj.Minute = "0" + obj.Minute;
            if (obj.Second < 10)
                obj.Second = "0" + obj.Second;

            box.text(obj.Hour + ":" + obj.Minute + ":" + obj.Second);
        }