# Strange getMonth/setMonth problem

**URL:** <https://forum.kirupa.com/t/strange-getmonth-setmonth-problem/205275>\
**Category:** web dev\
**Created:** [October 27, 2006, 4:13pm UTC](https://forum.kirupa.com/t/strange-getmonth-setmonth-problem/205275 "2006-10-27T16:13:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![aaroncampbell](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@aaroncampbell](https://forum.kirupa.com/u/aaroncampbell)\
**Post date:** [October 27, 2006, 4:13pm UTC](https://forum.kirupa.com/t/strange-getmonth-setmonth-problem/205275/1 "2006-10-27T16:13:56Z")

</div>

Ok, the code is attached, and you can use it by adding onfocus=“cal.showCal(this);” to any text input like this:

```auto
<input name="demo" type="text" maxlength="10" size="10" **onfocus="cal.showCal(this);"** />

```

Now, The problem I have it that the month down button doesn’t work, and the month up button goes 2 months at a time…except from Dec to Jan…which it does correctly.

Anyway, It sounds easy, but I tried manually changing the adjustment in the Calendar.prototype.changeMonth function like this:

```auto
this.current.setMonth(this.current.getMonth()+1);

```

And it still goes by 2. So I tried this:

```auto
this.current.setMonth(this.current.getMonth());

```

And it doesn’t change (as expected), so I tried this:

```auto
this.current.setMonth(this.current.getMonth()-1);

```

And it doesn’t change!!! How can this.current.getMonth()-1 == this.current.getMonth()!!!

Anyway, the problem is that creating a test case didn’t seem to work…I couldn’t repeat the glitch. Maybe someone can find my glaring error? I know that this system worked not that long ago…I HAVE made changes, but I have no idea where this went wrong…
