New Date() gets the wrong date? (SOLVED)

So I’m using an external javascript event to try to pull today’s date.
I’m using code such as:

var thedate = new Date();
monthvariable.setNumber(thedate.getMonth());

However, when I get the date, the year is correct, but it thinks that it’s July 4 (today is August 8).

Any idea what is causing this/how to fix it??
TIA

How are you getting the day. I got 4 as well but I used getDay() and it’s actually the day of the week. You need getDate() if you’re not using it.

Also, the month starts at 0. So, you need to add 1 to it.

Thank you so much!! That fixed all my problems :smile:

I wonder why the months start at 0 though, especially since the day of the month doesn’t?!
How strange :thinking:

1 Like

I’ve been getting one hour less but I think it’s due to my country not using daylight-saving

Yeah I’ve heard you have to watch out for which time zone your computer is using!