Skip to content Skip to sidebar Skip to footer

Need Help Displaying A Set Dynamic Date And Time

Basically I want my website to display my local time and date for everyone to see. Let's say it is currently 6:25 PM on December 17, 2014 in my time zone and a visitor to the site

Solution 1:

Uhm, your question is a bit vague. You just want a clock with date to be shown on your webpage? Unless you provide some code, I can't add it to your existing project, but I made a working code in HTML. With some inspiration from W3School (http://www.w3schools.com) I ended up with this:

<!DOCTYPE html><html><head><script>functionstartTime() {
                var today=newDate();
                var day = today.getDate();
                var month = today.getMonth();
                var year = today.getFullYear();
                var h=today.getHours();
                var m=today.getMinutes();
                var s=today.getSeconds();
                m = checkTime(m);
                s = checkTime(s);
                document.getElementById('txt').innerHTML = "Date: " + day + "/" + month + "/" + year + " " + "Clock: " + h+":"+m+":"+s;
                var t = setTimeout(function(){startTime()},500);
            }

            functioncheckTime(i) {
                if (i<10) {i = "0" + i};  // add zero in front of numbers < 10return i;
            }
        </script></head><bodyonload="startTime()"><divid="txt"></div></body></html>

Is this what you mean?

The edit is just that I made variables of the date too.

Post a Comment for "Need Help Displaying A Set Dynamic Date And Time"