# My digital clock doesn't seems to work well! help!

**URL:** <https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814>\
**Category:** Uncategorized\
**Created:** [May 19, 2002, 4:45pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814 "2002-05-19T16:45:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2002, 4:45pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/1 "2002-05-19T16:45:06Z")

</div>

I keep getting PM the whole day. Wht’s wrong with my AM?  
herewith my actionscript:

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2002, 5:27pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/2 "2002-05-19T17:27:23Z")

</div>

I’m a newbie so I don’t know if this is where the error lies but I’ll give it a shot:

if (hours\>=12) {  
ampm = “pm”;  
} else {  
ampm = “am”;  
}  
if (hours\>=13) {  
nHours = nHours-12;

Where the hell does the script get the hours from?! Maybe that’s the problem 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2002, 5:38pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/3 "2002-05-19T17:38:46Z")

</div>

correct. change every “hours” into “nHours” I made a mistake in the code that I sent to Kirupa. I’ll have him change it when he gets the time…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2002, 6:49pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/4 "2002-05-19T18:49:18Z")

</div>

thank you guys, i’ve been trying to figure it out long time ago…finally…thank you…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2002, 7:34pm UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/5 "2002-05-19T19:34:53Z")

</div>

Hey jubba,  
I updated the code 🙂

Cheers,  
Kirupa

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 20, 2002, 12:48am UTC](https://forum.kirupa.com/t/my-digital-clock-doesnt-seems-to-work-well-help/1814/6 "2002-05-20T00:48:33Z")

</div>

Thanks Kirupa. When I wrote those tutorials I didn’t copy and paste the code, I re-wrote it into the Word document…ruff times…sorry abuot the screw-ups 🙂
