Text Scroll

You must welcome, Thank you for visiting my blog.

Search This Blog

Monday, June 29, 2020

Add a Digital clock in MS form using java script.

function displayTime() {

            var ob = new Date();
            var year = ob.getFullYear();
            var month = ob.getMonth() + 1;
            var date = ob.getDate();
            var hours = ob.getHours();
            var minutes = ob.getMinutes();
            var seconds = ob.getSeconds();
            var indicator = "AM";
            if (hours >= 12) {
                indicator = "PM";
            }
            if (hours > 12) {
                hours = hours - 12;
            }
            if (month <= 9) {
                month = "0" + month;
            }
            if (date <= 9) {
                date = "0" + date;
            }
            if (hours <= 9) {
                hours = "0" + hours;
            }
            if (minutes <= 9) {
                minutes = "0" + minutes;
            }
            if (seconds <= 9) {
                seconds = "0" + seconds;
            }
            var completeDate = date + "-" + month + "-" + year + " " + hours + ":" + minutes + ":" + seconds + " " + indicator;
            document.getElementById("divDisplayTime").innerHTML = completeDate;
        }// End of displayTime() function
        setInterval("displayTime()", 1000);


**Note:
Use HTML web resources and use a text field with id "divDisplayTime"

No comments:

Post a Comment