So I have a HTML website (not actually online) and I'm just messing around with it. Recently I added a clock, however, after doing a lot of editing with it, there seems to be an error that I can't find. Here is the code:
<!DOCTYPE html>
<html>
<script type="text/javascript">
<!--
function updateTime() { var monthNames = ["January", "February", "March", "April", "May", "June
function updateTime() {
var currentTime = new Date();
var dayWk = currentTime.getDay();
var year = currentTime.getYear() - 100 + 2000;
var month = monthNames[currentTime.getMonth()];
var date = currentTime.getDate();
var hours = currentTime.getHours();
var minutes = currentTime.getMinutes();
var seconds = currentTime.getSeconds();
var dayWkNm = " ";
var dateFuncVar = date;
var dateSuffix = " ";
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
if (dayWk == 0){
dayWkNm = "Sunday";
}
if (dayWk == 1){
dayWkNm = "Monday";
}
if (dayWk == 2){
dayWkNm = "Tuesday";
}
if (dayWk == 3){
dayWkNm = "Wednesday";
}
if (dayWk == 4){
dayWkNm = "Thursday";
}
if (dayWk == 5){
dayWkNm = "Friday";
}
if (dayWk == 6){
dayWkNm = "Saturday";
}
function dateFunc(dateFuncVar) {
while (dateFuncVar > 9) {
dateFuncVar = dateFuncVar - 10;
}
if (dateFuncVar == 1){
dateSuffix = "st";
} else if (dateFuncVar == 2){
dateSuffix = "nd";
} else if (dateFuncVar == 3){
dateSuffix = "rd";
} else {
dateSuffix = "th";
}
return dateFuncVar;
}
var text = dayWkNm + "the" + date + " of " + month + ", " + year + " " + hours + ":" + minutes + ":" + seconds;
if(hours > 11){
text+=" PM";
hours = hours - 12;
} else {
text+=" AM";
}
document.getElementById("time").innerHTML=text;
}
setInterval(updateTime, 1000);
//-->
</script>
<head>
<title>
Welcome to the Goto home page
</title>
<h3>
<p style="text-align:right" id="time">
</p>
</h3>
</head>