Digital clock

I’m making a digital clock to put on my site. I used the tutorial from here on kirupa but i’m still having some trouble. For the minutes and hours, if the value is less than 10 it should have a zero in front of it, but it’s not showing up for me. I used the code that he had posted:

onClipEvent (enterFrame) {
myTime = new Date();
nSeconds = myTime.getSeconds();
nMinutes = myTime.getMinutes();
nHours = myTime.getHours();
if (nHours>=12) {
ampm = “pm”;
} else {
ampm = “am”;
if (nHours>=13) {
nHours = nHours-12;
if (nHours==0) {
nHours = 12;
if (length(nMinutes) == 1) {
nHinutes = “0”+nMinutes;
if (length(nSeconds) == 1) {
nSeconds = “0”+nSeconds;
nTime = nHours+":"+nMinutes+":"+nSeconds+" "+ampm;

what’s wrong? Thanks!

I still can’t figure it out, it seems like the code should work, but i’m still not getting the zeros in front of the minutes or seconds. Anyone got any ideas?

It should work, although length() is a deprecated function.
Also, there’s a typo on your code:

 if (length(nMinutes) == 1) {
n**M**inutes = "0"+nMinutes;

Thanks man, i got the tutorial from here but didn’t even think to check for typos. it works now :pleased:

Anytime :wink: