0

I am instantiating a Javascript Date object in my script using the setFullYear, setMonth,....methods in the Date object. But the resulting Date object shows the year and month as 1+. For example if I set the year to 2012 and month to 12. The Date object would show up as 2013, January....

How can I avoid this?

Thanks.

4

1 に答える 1

3

月はゼロから始まります。12 月には 11 を設定する必要があります。

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/setMonth

于 2012-12-07T02:13:14.407 に答える