# Digital clock tweaks

**URL:** <https://forum.kirupa.com/t/digital-clock-tweaks/272982>\
**Category:** flash\
**Created:** [October 9, 2008, 9:12pm UTC](https://forum.kirupa.com/t/digital-clock-tweaks/272982 "2008-10-09T21:12:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tcg](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@tcg](https://forum.kirupa.com/u/tcg)\
**Post date:** [October 9, 2008, 9:12pm UTC](https://forum.kirupa.com/t/digital-clock-tweaks/272982/1 "2008-10-09T21:12:18Z")

</div>

Hi,

I used J.E. aka IamNot Jubba’s Digital Clock tutorial to create 4 different world clocks. I tweaked his code to make each clock 24-hour (military time), then I offset each clock for 4 different locations (+0 hours for SF, +7 hours for UK, +9 for SA, +3 for NYC). Check out the code for SA:

onClipEvent (enterFrame) {  
myTime = new Date();  
nSeconds = myTime.getSeconds();  
nMinutes = myTime.getMinutes();  
nHours = myTime.getHours() + 9;

```
if (length(nMinutes) == 1) {
    nMinutes = "0"+nMinutes;
}
if (length(nSeconds) == 1) {
    nSeconds = "0"+nSeconds;
}
nTime = nHours+":"+nMinutes+":"+nSeconds;

```

}

My question is how to adjust the code so the hours don’t “break” after 23:00 hours (11pm in regular time). For example if it’s 4:00pm in South Africa, my clock incorrectly displays 31:00- it should read 16:00. I tried adding this line but no go:

if (nHours\>=23) {  
nHours = nHours-9;  
}

Any math/flash geniouses out there wanna take crack at this? I’d really appreciate any help.

Thanks!  
tcg
