I'm using a simple javascript to display the local time in my country on a website, but it seems to be broken. After 12 midnight, by right the clock should reset to AM instead, but it keeps showing the time in PM (eg. 1 PM instead of 1 AM)

Body:

```
<body onload="updateClock(); setInterval('updateClock()', 1000 )">

//div tags, elements etc

</body>

```

JS:

```
function updateClock (){

var currentTime =  new Date();
var currentHours = currentTime.getUTCHours() + 8; 
var currentMinutes = currentTime.getUTCMinutes();
var currentSeconds = currentTime.getUTCSeconds();

// var bucurestiOffset = 3*60000;
// var userOffset = currentTime.getTimezoneOffset()*60000;

currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

var timeOfDay = ( currentHours < 12 ) ? "AM" : "PM";
currentHours = ( currentHours > 12 ) ? currentHours - 12 : currentHours;
currentHours = ( currentHours == 0 ) ? 12 : currentHours;

var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
  document.getElementById("clock").firstChild.nodeValue = currentTimeString;
}

```

Result: 13:52:40 PM. Current time where im located is 1:52 AM.
Don't know how to go about fixing this.