0

I'm trying to make my digital clock change from AM to PM when it needs too. But it will only stay on AM even when it should be on PM. And it needs to be the same time as the time set on the computer. Care to help? Thanks guys, here's my code :

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Current Time</title>

<style>
.mytime {font-size: 150px;
         margin: 0 auto;
         padding: 10px;
         color: #ffffff;
         font-weight: bold;
         text-align: center;
        }

.myTxt {font-size: 72px;
         margin: 0 auto;
         padding: 10px;
         color: #ffffff;
         font-weight: bold;
         text-align: center;
        }
</style>
</head>

<body style="background-color: #000;">

<div ID="TimeBlock" class="mytime"></div>

<div ID="Content" class="myTxt"><small>Brought to you by</small> <br>Nate
        <br /><br /><br />
        A Simulated Workplace Environment 

`enter code here`</div>

    <script type="text/javascript" langauage="javascr

ipt">
function renderTime() {
    var currentTime = new Date();
    var diem = "AM";
    var h = currentTime.getHours();
    var m = currentTime.getMinutes();
    var s = currentTime.getSeconds();

    if (h == 0) {
        h = 12;
        } 
        else if (h > 12) {
        h = h - 12
        diem = "PM";
        }
            if (h < 10) {
            h = "0" + h 
            }
            if (m < 10) {
            m = "0" + m 
            }
            if (s < 10) {
            s = "0" + s 
            }
    var myDisplayTime = document.getElementById("TimeBlock");
    myDisplayTime.textContent = h + ":" + m + ":" + s + " " + diem;
    myDisplayTime.innerText = h + ":" + m + ":" + s + " " + diem;
    setTimeout('renderTime()', 1000);
    }
renderTime();

</script>


<script>
alert("Open this?")
</script>



</body>

0 Answers0