Help! digital clock - am and pm?

Im doing a world clock. I dont know how to make the ‘ampm’ thing. I tried to do it by making some variable - ampm and made my code tried to make it for example:

[COLOR=Blue]if/COLOR {
hours=hours-24;
}
to become

[COLOR=Blue]if/COLOR {
hours=hours-12;
}
[COLOR=Blue]if /COLOR {
ampm=“AM”;
} [COLOR=Blue]else[/COLOR] {
ampm=“PM”;
}

but maybe Im not doing it right cause the code doesnt work it shows me AM all the time. For now my clock works normally with 24 hour system - I mean 5:00 pm is 17:00. But I would like to make it in the way so it to look like 05:00pm. Do you know some tutorials for AM and PM specially?
For now its made in the following way:

[COLOR=Blue]function[/COLOR] UpdateClock(){
myDate = [COLOR=Blue]new Date/COLOR;
hours = myDate.[COLOR=Blue]getUTCHours/COLOR;
[COLOR=Blue]if/COLOR {
hours=hours-24;
}
minutes = myDate.[COLOR=Blue]getMinutes/COLOR;
seconds = myDate.[COLOR=Blue]getSeconds/COLOR;
sofia = myDate.[COLOR=Blue]getUTCHours/COLOR+2;
[COLOR=Blue]if/COLOR {
sofia=sofia-24;
}
minutes = myDate.[COLOR=Blue]getMinutes/COLOR;
seconds = myDate.[COLOR=Blue]getSeconds/COLOR;
}

[COLOR=Blue]if[/COLOR] (hours<10) {
hours = “0”+hours;

}
if (sofia<10) {
sofia = “0”+sofia;

}


if(hours>12) {
ampm="PM";
hours -= 12;
}else if (hour == 0) {
hour = 12;
} else {
ampm = "AM";
}

salut

Digital: http://www.n99creations.com/?pID=archives&col=Blue&arch=Digital_Clock
Analogue: http://www.n99creations.com/?pID=archives&col=Blue&arch=Analogue_Clock

EDIT:
Second, I will make a world one.
http://www.n99creations.com/?pID=archives&col=Blue , should be there