I want to add a live, digital clock and the date to my site

Anyone could help with my issue? It’s not working for me, following the code:

<script> 
  .auto-date {
  	window.days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
    window.months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
        function nthFormatter(d) {
            if (d > 3 && d < 21) return 'th';
            switch (d % 10) {
                case 1: return "st";
                case 2: return "nd";
                case 3: return "rd";
                default: return "th";
                }
        }
        function currentTime() {
            var date = new Date();
            var hour = date.getHours();
            var min = date.getMinutes();
            if (min < 10)
                min = "0" + min;
            var ampm = hour >= 12 ? 'pm' : 'am';
            var dayOfWeek = window.days[date.getDay()];
            var month = window.months[date.getMonth()];
            var day = date.getDate();
            day += nthFormatter(day);
  			const autodate = {
    				weekday: “short”,
    				month:”short”
  			}
            var t = setTimeout(function () { currentTime() }, 15000); 
        currentTime();
	}
</script>

Hey guys! I was able to add a clock to my website successfully thanks to the code snippet.

When I copy and paste the div that includes the code snippet, the clock doesn’t show up in these new pasted “instances” of the clock (still visible in the original div). Aside from refreshing Designer, I tried to change the ID and the name of the div with clock2,3,4,etc and update the coed snippet with each new ID but it doesn’t work unfortunately.

Anyone has an idea of how to add multiple clock in the same page using this snippet? :crossed_fingers:

Thank you guys :yellow_heart:

PS: Also, if anyone would know how to format the clock as “3:21pm” instead of “15:21pm”…? :relaxed:

it might too late for this reply to help you, but it will probably help someone from the future so here it goes:
To change the time format from 24h to 12h am/pm just add the following code to your script

var ampm = hour >= 12 ? 'pm' : 'am';
hour = hour % 12;
hour = hour ? hour : 12;

Hey! I know this is an older post, but for those still looking.

We added a solution for this through our Booster attributes.

It uses UTC, and you can add it with just a few attributes.

Cheers! :smile: