# Digital clock woes

**URL:** <https://forum.kirupa.com/t/digital-clock-woes/62996>\
**Category:** Uncategorized\
**Created:** [September 2, 2004, 4:05am UTC](https://forum.kirupa.com/t/digital-clock-woes/62996 "2004-09-02T04:05:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tajmahal](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@tajmahal](https://forum.kirupa.com/u/tajmahal)\
**Post date:** [September 2, 2004, 4:05am UTC](https://forum.kirupa.com/t/digital-clock-woes/62996/1 "2004-09-02T04:05:30Z")

</div>

I know, I know, another clock question from another dumb newbie…

In MX, is it possible to have a digital clock thats not in 24-hr time (ie. 7:05 instead of 19:05)? I’ve seen it on the net before, but i think they were created in MX2004…am i wrong? :h:

Also, in my clock, when i have seconds or minutes less than ten, they’re displayed with only one digit (ie. 5:3:2 is shown at 5:03:02). How do i fix this? Some if statements perhaps?:huh:

I hope I didn’t have anything here that was written anywhere else in the forums - i looked, but i didn’t find. :crying:

Thanks!

---

<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:** [September 2, 2004, 4:48pm UTC](https://forum.kirupa.com/t/digital-clock-woes/62996/2 "2004-09-02T16:48:15Z")

</div>

i’m not at my own computer right now so i don’t have the exact code in front of me, but it needs if statements. example:

```auto

if (minutes < 10) {
    outputtext = "0" + minutes;
}

```

as for the 12 hours thing, it’s the same.

```auto

if (hours > 12){
    hours = hours - 12;
}

```

again, this isn’t very detailed, but when i get back to my computer, i’ll post the code I used for mine.

---

<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:** [September 3, 2004, 6:22pm UTC](https://forum.kirupa.com/t/digital-clock-woes/62996/3 "2004-09-03T18:22:14Z")

</div>

ok, here’s the code that i used for mine:

```auto

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) {
        nMinutes = "0"+nMinutes;
    }
    if (length(nSeconds) == 1) {
        nSeconds = "0"+nSeconds;
    }
    nTime = nHours+":"+nMinutes+":"+nSeconds+" "+ampm;
}

```

where nTime is the variable name of the dynamic textbox that you’re outputing to.

does this help?

---

<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:** [September 3, 2004, 9:06pm UTC](https://forum.kirupa.com/t/digital-clock-woes/62996/4 "2004-09-03T21:06:43Z")

</div>

everything is working perfect! you’re awesome! :p:
