I need some help with time script

: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…

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!!

<:}

Try this:

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

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…

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 it is my cs clan…I guess the site is ok…I finished it about a day ago.

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.


// 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();
}

Awesome! I’m glad you got it! :slight_smile: