# New Date problem!

**URL:** <https://forum.kirupa.com/t/new-date-problem/7918>\
**Category:** Uncategorized\
**Created:** [November 10, 2002, 9:18am UTC](https://forum.kirupa.com/t/new-date-problem/7918 "2002-11-10T09:18:39Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [November 10, 2002, 9:18am UTC](https://forum.kirupa.com/t/new-date-problem/7918/1 "2002-11-10T09:18:39Z")

</div>

I didn’t have this problem with Flash 5… I think 🙂  
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 ☹  
i tried  
if(lentgh(hours==1)) {  
hours = “0”+hours;  
}  
…still didn’t work… ☹  
Any ideas?

---

<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:** [November 10, 2002, 9:41am UTC](https://forum.kirupa.com/t/new-date-problem/7918/2 "2002-11-10T09:41:52Z")

</div>

This should work:

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

yours,  
h88

\*\*PS you can use the [\*PHP]

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

---

<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:** [November 10, 2002, 11:07am UTC](https://forum.kirupa.com/t/new-date-problem/7918/3 "2002-11-10T11:07:40Z")

</div>

:P:P:P  
Why didn’t I think of that???  
:P:P:P

---

<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:** [November 10, 2002, 11:08am UTC](https://forum.kirupa.com/t/new-date-problem/7918/4 "2002-11-10T11:08:20Z")

</div>

Did that work! 😛

---

<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:** [November 10, 2002, 11:39am UTC](https://forum.kirupa.com/t/new-date-problem/7918/5 "2002-11-10T11:39:41Z")

</div>

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

```php
myyear = mydate.getYear();

```

(PHP PHP PHP :P)  
i didn’t know that the year is 102!  
The date is today:  
10.11.102  
cool  
wtf? Time travelling? have I gone back in time?? 🙂

* * *

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!

---

<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:** [November 10, 2002, 11:41am UTC](https://forum.kirupa.com/t/new-date-problem/7918/6 "2002-11-10T11:41:16Z")

</div>

I’ll work on it now =)

---

<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:** [November 10, 2002, 11:44am UTC](https://forum.kirupa.com/t/new-date-problem/7918/7 "2002-11-10T11:44:07Z")

</div>

solution:

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

```

---

<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:** [November 10, 2002, 11:46am UTC](https://forum.kirupa.com/t/new-date-problem/7918/8 "2002-11-10T11:46:44Z")

</div>

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!

yours,  
h88

---

<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:** [November 10, 2002, 12:45pm UTC](https://forum.kirupa.com/t/new-date-problem/7918/9 "2002-11-10T12:45:13Z")

</div>

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

---

<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:** [November 10, 2002, 12:46pm UTC](https://forum.kirupa.com/t/new-date-problem/7918/10 "2002-11-10T12:46:02Z")

</div>

no problem!
