New Date problem!

I didn’t have this problem with Flash 5… I think :slight_smile:
But anyway
myhours = getHours(); no problem
but when the hours are 1-9 I want “0” to be in front of the hours.
like not “9.44.56” but “09.44.56”
I tried
if(hours<10) {
hours = “0”+hours;
but It didn’t work :frowning:
i tried
if(lentgh(hours==1)) {
hours = “0”+hours;
…still didn’t work… :frowning:
Any ideas?

This should work:

myDate = new Date();
Hours = (myDate.getHours())
if (Hours <= 9) {
	myDate1 = ("0"+Hours+":"+(myDate.getMinutes()))
} else {
myDate1 = (Hours+":"+(myDate.getMinutes()))
DynamicTextField.text = myDate1

Hope this helps!


**PS you can use the [*PHP]

(w/o the *) tags to add syntax highlighting and formatting to your code.**

Why didn’t I think of that???

Did that work! :stuck_out_tongue:

Yes it worked but another problem occured.(not because of this)
I didn’t add the year before but now i noticed that the year is missing and I added

myyear = mydate.getYear();

i didn’t know that the year is 102!
The date is today:
wtf? Time travelling? have I gone back in time?? :slight_smile:

oh and btw!
The month is 10. but it should be 11(Nov). Why is that so?
I just made it mymonth+1 but why does it showme 10???
man I can’t get the easiest things working lately!

I’ll work on it now =)


myDate = new Date();
DynamicTextField.text = ((myDate.getYear()) + 1900)

and about the month thingy:

returns the month (0 for January, 1 for February, and so on) of the specified Date object, according to local time. Local time is determined by the operating system on which the Flash Player is running.

so just add 1 and it would work!


oh thx! =)
I’m making my homepage and you helped a lot!
Thanx a bunch!

no problem!