PDA

View Full Version : Need Date and Time Help...



emeX
August 3rd, 2003, 06:01 PM
How do i make the date and time if its less than 10 to display a zero in front so for example like four o six and and six seconds looks like this 04:06:06 instead of this 4:6:6. also how do you do this with a date i want a date have only 2 digits for the year and if the month and day are less than 10 to display a zero in front of them...

claudio
August 3rd, 2003, 06:49 PM
Create a movie clip with 3 textfields inside and set their variables as:
myhours
myminutes
myseconds

Now place the folllowing actions on the movie clip:onClipEvent (enterFrame) {
myDate = new Date();
hours = myDate.getHours();
minutes = myDate.getMinutes();
seconds = myDate.getSeconds();
myhours = hours;
myminutes = minutes;
myseconds = seconds;
(hours<10) ? myhours="0"+hours : myhours=hours;
(minutes<10) ? myminutes="0"+minutes : myminutes=minutes;
(seconds<10) ? myseconds="0"+seconds : myseconds=seconds;
}

brainy
August 4th, 2003, 06:33 AM
hmm, this could be compacted to this:


onClipEvent (enterFrame) {
var myDate = new Date();
var hours = myDate.getHours();
var minutes = myDate.getMinutes();
var seconds = myDate.getSeconds();
myhours = (hours<10) ? "0"+hours : hours;
myminutes = (minutes<10) ? "0"+minutes : minutes;
myseconds = (seconds<10) ? "0"+seconds : seconds;
}

emeX
August 4th, 2003, 09:50 AM
Awesome.. thanks

claudio
August 4th, 2003, 10:12 AM
welcome :)