Nepali clock || Nepali Java clock || Nepali server clock with seconds || Nepali clock code

 Nepali clock || Nepali Java clock || Nepali server clock with seconds || Nepali clock code



You can check Nepali clock widget for iframe.


<!DOCTYPE html>

<html>

<head>

    <title>Nepali Time Clock</title>

    <style>

        #clock {

            font-size: 48px;

            text-align: center;

            margin-top: 100px;

            font-family: "Noto Sans Devanagari", Arial, sans-serif;

        }

    </style>

    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+Devanagari:wght@500&display=swap" rel="stylesheet">

</head>

<body>

    <div id="clock"></div>


    <script>

        function updateTime() {

            var date = new Date();

            var nepalTimeZoneOffset = 5.75; // Nepal (Kathmandu) timezone offset in hours

            var nepaliTime = convertToNepaliTime(date, nepalTimeZoneOffset);

            var hours = nepaliTime.getHours();

            var minutes = nepaliTime.getMinutes();

            var seconds = nepaliTime.getSeconds();


            var devanagariHours = convertToDevanagari(hours);

            var devanagariMinutes = convertToDevanagari(minutes);

            var devanagariSeconds = convertToDevanagari(seconds);


            var time = devanagariHours + ":" + devanagariMinutes + ":" + devanagariSeconds;

            document.getElementById("clock").innerHTML = time;


            setTimeout(updateTime, 1000); // Update every 1 second

        }


        function convertToNepaliTime(date, timeZoneOffset) {

            var utcTime = date.getTime() + (date.getTimezoneOffset() * 60000);

            var nepalTime = utcTime + (timeZoneOffset * 3600000);


            return new Date(nepalTime);

        }


        function convertToDevanagari(number) {

            var devanagariDigits = ["०", "१", "२", "३", "४", "५", "६", "७", "८", "९"];

            var numberString = number.toString();

            var devanagariNumber = "";


            for (var i = 0; i < numberString.length; i++) {

                var digit = parseInt(numberString.charAt(i));

                devanagariNumber += devanagariDigits[digit];

            }


            return devanagariNumber;

        }


        updateTime(); // Start the clock

    </script>

</body>

</html>


Previous Post Next Post