I suppose this is absolute novice question in javascript.
I want to know what do ‘-‘ mean in javascript date.
Example: new Date(2010, 12 – 1, 10, 22, 00, 00);
What does 12 – 1 say in the above.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s subtracting one to get
11.Why? It’s usually the result of an earlier month number being “off” one, because
.getMonth()is 0-based, where other date parts are 1-based. The signature forDate()looks like this:…but the
monthparameter is0-11, where theyearanddateparameters are1-based. You think of12as December, but being 0-based, it’s11not12…the code style you’re seeing is one way to express that or at least make you go “wait a second…” and see that it’s notNovember, as you’d intuitively think if the author just put “11” there.