Clock

i´m using this code to make a digital clock:

onClipEvent (enterFrame) {
myTime = new Date();
nMinutes = myTime.getMinutes();
nHours = myTime.getHours();

if (hours>=13) {
	nHours = nHours-12;
}
if (length(nMinutes) <= 1) {
	nHinutes = "0"+nMinutes;
}
	nTime = nHours+":"+nMinutes+nSeconds+" "+ampm;

}

The problem is that when the minutes are <10, it´s shown like this>

13:9 pm

how do I solve this?^

thanks

the code is wrong.


if (length(nMinutes) <= 1) {
nHinutes = "0"+nMinutes;
}

should be


if (length(nMinutes) <= 1) {
nMinutes = "0"+nMinutes;
}

I DON´T BELIVE IT!!!

I didn´t see it!
thanks a lot

did you take that from the tutorial on this site? That looks like my code… There is a mistake on the tutorial code that I gave Kirupa because I was in a rush to write it. Been there for a while, Kirupa hasn’t gotten a chance to modify it yet…

I’ll bring it up to him again. :slight_smile:

yes, that´s from kirupas tutorial, but I changed and got just the hour.