# I need some help with time script

**URL:** <https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649>\
**Category:** Uncategorized\
**Created:** [December 16, 2002, 1:07am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649 "2002-12-16T01:07:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![titter](https://avatars.discourse-cdn.com/v4/letter/t/f0a364/32.png) [@titter](https://forum.kirupa.com/u/titter)\
**Post date:** [December 16, 2002, 1:07am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/1 "2002-12-16T01:07:55Z")

</div>

:q: Ok well, I had this script all figured out…but now it seems to only show minutes and seconds and keep the hour at 12. Any help is a appreciated…here is my code:

onClipEvent (load) {  
days = new Array(‘Sunday’, ‘Monday’, ‘Tuesday’, ‘Wednesday’, ‘Thursday’, ‘Friday’, ‘Saturday’, ‘Sunday’);  
months = new Array(‘January’, ‘February’, ‘March’, ‘April’, ‘May’, ‘June’, ‘July’, ‘August’, ‘September’, ‘October’, ‘November’, ‘December’);  
timedate = new Date();  
}  
onClipEvent (enterFrame) {  
meridian = “AM”;  
hour = (timedate.getHours());  
minutes = timedate.getMinutes();  
seconds = timedate.getSeconds();  
todaydate = timedate.getDate();  
day = timedate.getDay();  
dayname = days[day];  
month = (timedate.getMonth()+1);  
monthname = months[month-1];  
year = timedate.getFullYear();  
if (hour=12) {  
meridian = “PM”;  
}  
if (hour\>12) {  
hour = hour-12;  
meridian = “PM”;  
}  
if (length(minutes) == 1) {  
minutes = “0”+minutes;  
}  
if (length(seconds) == 1) {  
seconds = “0”+seconds;  
}  
currenttime = hour+":"+minutes+":"+seconds+ “” +meridian;  
currentdate = todaydate+"/"+month+"/"+year;  
fulldate = dayname+", “+monthname+” “+todaydate+”, "+year;  
delete timedate;  
timedate = new Date();  
}

The date works perfectly…now only iof the hours would wokr I will be a happy flasher…

---

<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:** [December 16, 2002, 2:13am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/2 "2002-12-16T02:13:01Z")

</div>

I have an fla with all that stuff, i will post it to you soon as i find it.  
or  
If you can PM a guy called “soulty” im sure he will send it to you, he recently just used it in one of his projects.

You can find him in the actionscript post sumpin like {f5} a rue challenge or sumpin.

If he doesnt reply post here, and ill call him, he lives nearby!!

\<:}

Of course if i find it, ill post it here for 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:** [December 16, 2002, 2:21am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/3 "2002-12-16T02:21:38Z")

</div>

Try this:

```php
onClipEvent (load) {
    mon = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Oct", "Nov", "Dec"];
    weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
}
onClipEvent (enterFrame) {
    now = new Date();
    nDay = weekdays[now.getDay()];
    nMonth = mon[now.getMonth()];
    nDate = now.getDate();
    nYear = now.getFullYear();
        nSeconds = now.getSeconds();
    nMinutes = now.getMinutes();
    nHours = now.getHours();
    if (nHours>=12) {
        ampm = "pm";
    } else {
        ampm = "am";
    }
    if (nHours>=13) {
        nHours = nHours-12;
    }
    if (length(nMinutes) == 1) {
        nMinutes = "0"+nMinutes;
    }
    if (length(nSeconds) == 1) {
        nSeconds = "0"+nSeconds;
    }
    displayDate = nMonth+" "+nDate+", "+nYear;
    displayDay = nDay;
    nTime = nHours+":"+nMinutes+":"+nSeconds+" "+ampm;
}

 

```

where displayDate displayDay and nTime are the name of the dynamic text boxes…

Heres the link to the tutorial:

[http://www.kirupa.com/developer/actionscript/digital\_clock.asp](http://www.kirupa.com/developer/actionscript/digital_clock.asp)

Sorry, I’m not really that great at debugging code when I don’t have Flash installed, and I can’t just look at it on the forum… Hope this helps…

---

<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:** [December 16, 2002, 12:25pm UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/4 "2002-12-16T12:25:59Z")

</div>

I appreciate your help, lemme go see what I can do with this after some exams at school. Anyway…here is the site that it is on:  
[www.apocalypseclan.net](http://www.apocalypseclan.net) it is my cs clan…I guess the site is ok…I finished it about a day ago.

---

<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:** [December 17, 2002, 2:48am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/5 "2002-12-17T02:48:25Z")

</div>

Thanks Jubba! I debugged my code and this is the outcome I got form my orignal code. If you would like to see the source, tell me and I will post.

```php

// This creates two ARRAYs that swap returned numbers with values (i.e. 0=Sunday, 4=Thursday & 1=January, 7=August)
onClipEvent (load) {
	days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
	months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
	timedate = new Date();
}
// This action actually calls out to the users system to grab the current date and time
// The date is grabbed from the ARRAYs earlier set
onClipEvent (enterFrame) {
	now = new Date();
	todaydate = timedate.getDate();
	day = timedate.getDay();
	dayname = days[day];
	month = (timedate.getMonth()+1);
	monthname = months[month-1];
	year = timedate.getFullYear();
	seconds = now.getSeconds();
    minutes = now.getMinutes();
    hours = now.getHours();
    if (Hours>=12) {
        ampm = "pm";
    } else {
        ampm = "am";
    }
    if (Hours>=13) {
        Hours = Hours-12;
    }
    if (length(Minutes) == 1) {
        Minutes = "0"+Minutes;
    }
    if (length(Seconds) == 1) {
        Seconds = "0"+Seconds;
    }
	currenttime = Hours+":"+Minutes+":"+Seconds+" "+ampm;
	currentdate = todaydate+"/"+month+"/"+year;
	fulldate = dayname+", "+monthname+" "+todaydate+", "+year;
	delete timedate;
	timedate = new Date();
}

```

---

<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:** [December 17, 2002, 4:16am UTC](https://forum.kirupa.com/t/i-need-some-help-with-time-script/9649/6 "2002-12-17T04:16:02Z")

</div>

Awesome! I’m glad you got it! 🙂
