Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Web Technology by (7k points)

I have this string 30/11/2011. I want to convert it to a date object.

Do I have to use:

Date d = new Date(2011,11,30);

Or

Date d = new Date(2011,10,30);  

1 Answer

0 votes
by (13.1k points)

You have to use

var d = new Date(2011,10,30);

As months are indexed from 0 in JavaScript.

Want to learn full stack development? Check out the full-stack developer course from Intellipaat.

Related questions

0 votes
1 answer
0 votes
0 answers
0 votes
1 answer
asked Mar 15, 2021 in Java by dante07 (13.1k points)
0 votes
0 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...