# \[MX\] Date object problem

**URL:** https://forum.kirupa.com/t/mx-date-object-problem/24883
**Category:** flash
**Created:** [July 6, 2003, 6:04pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883 "2003-07-06T18:04:40Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Keith130](https://avatars.discourse-cdn.com/v4/letter/k/b38774/32.png) [@Keith130](https://forum.kirupa.com/u/Keith130)
#### Post date: [July 6, 2003, 6:04pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/1 "2003-07-06T18:04:40Z")

</div>

I have the following AS on a frame :  
[AS]  
stop();  
myDate = new Date();  
myTime = new Date();  
\_root.main.txtDate = myDate.getUTCDate()+" / “+myDate.getUTCMonth+” / “+myDate.getFullYear();  
changeDate = setInterval(timeChange, 10);  
function timeChange() {  
\_root.main.txtTime = myTime.getUTCHours()+”:"+myTime.getUTCMinutes()+"."+myTime.getUTCSeconds();  
}[/AS]

It worksish and gives a date but the date is “6/6/2003” and the time is “18:3:4”. AS you can see both the month and the hour are one short. I tired setting a variable as ther month and addin one to it but the output was NaN.

Oh and the setInterval doesnt change the time?? Any ideas about that?  
Thanx in advance if you can help.

---

<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: [July 6, 2003, 6:17pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/2 "2003-07-06T18:17:45Z")

</div>

Try replacing for dis code:[AS]  
myDate = new Date();  
myTime = new Date();  
\_root.main.txtDate = (myDate.getUTCDate()+" / “+(myDate.getUTCMonth()+1)+” / “+myDate.getFullYear());  
changeDate = setInterval(timeChange, 10);  
function timeChange() {  
\_root.main.txtTime = ((myTime.getUTCHours()+1)+”:"+myTime.getUTCMinutes()+"."+myTime.getUTCSeconds());  
}  
stop();  
[/AS]  
I keep missing a +!!!

---

<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: [July 6, 2003, 6:23pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/3 "2003-07-06T18:23:25Z")

</div>

caludio solved your first issue, as of your second, try creating the date object everytime the function is called:

```auto
myDate = new Date();
_root.main.txtDate = (myDate.getUTCDate()+" / "+(myDate.getUTCMonth()+1)+" / "+myDate.getFullYear());
changeDate = setInterval(timeChange, 10);
function timeChange() {
        _root.main.txtTime = ((new Date().getUTCHours()+1)+":"+new Date().getUTCMinutes()+"."+new Date().getUTCSeconds());
}
stop();

```

---

<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: [July 7, 2003, 10:10am UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/4 "2003-07-07T10:10:41Z")

</div>

Thanx both of you, Now I see where I went wrong adding 1 to the month and hour. I nerver thought of declaring a new date everytime inside the function. I suppose it was like my Drag and Drop while easeing thing that I needed a function inside the button.onPress to update the targetX and targetY. Thanx again.

To see the calender in action go [**HERE**](http://www33.brinkster.com/blowtorch/TGS/site1.html)

---

<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: [July 7, 2003, 9:14pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/5 "2003-07-07T21:14:51Z")

</div>

No problem 🙂

---

<div class="post-metadata">

### Author: ![Edenbridge](https://avatars.discourse-cdn.com/v4/letter/e/97f17d/32.png) [@Edenbridge](https://forum.kirupa.com/u/Edenbridge)
#### Post date: [March 30, 2006, 6:52pm UTC](https://forum.kirupa.com/t/mx-date-object-problem/24883/6 "2006-03-30T18:52:48Z")

</div>

> [@PinnedBot](#):
>
> ActionScript Code:
> 
> [FONT=Courier New][LEFT]myDate = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Date[/COLOR]COLOR=#000000[/COLOR];\</p\>  
> …  
> \<p\>function timeChangeCOLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
> \<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]main[/COLOR].[COLOR=#000080]txtTime[/COLOR] = [COLOR=#000000]([/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Date[/COLOR]COLOR=#000000[/COLOR].[COLOR=#0000ff]getUTCHours[/COLOR]COLOR=#000000[/COLOR]+[COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR]+[COLOR=#ff0000]“:”[/COLOR]+[COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Date[/COLOR]COLOR=#000000[/COLOR].[COLOR=#0000ff]getUTCMinutes[/COLOR]COLOR=#000000[/COLOR]+[COLOR=#ff0000]“.”[/COLOR]+[COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Date[/COLOR]COLOR=#000000[/COLOR].[COLOR=#0000ff]getUTCSeconds[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];\</p\>  
> \<p\>[COLOR=#000000]}[/COLOR]\</p\>  
> \<p\>stopCOLOR=#000000[/COLOR];
> 
> [/LEFT]
> 
> [/FONT]

PinnedBot 🙂 sorry that I ask you, but Isnt it the same if you use myDate.[COLOR=blue]getUTCHours/COLOR or  
[COLOR=black] **new** [/COLOR] [COLOR=blue]Date/COLOR.[COLOR=blue]getUTCHours/COLOR? I was thinking it is the same thing but as I see there is difference…Ihave also problem with digital world clock thats why Im asking.
