How to Create Date object from year month value?

We can pass in numbers to Date class constructors.

the year,

the zero-based month (January is 0, February is 1, and so on)

the day of the month (1 through 31),

the hours (0 through 23),




The year and month are required.



        var aDate = new Date(2012, 4, 5, 17, 55, 55); 


        //Sat May 05 2012 17:55:55 GMT-0700 (Pacific Daylight Time)




If the day of the month isn't supplied, it's assumed to be 1. all other omitted arguments are assumed to be 0.


    var aDate = new Date(2012, 0); 


    //Sun Jan 01 2012 00:00:00 GMT-0800 (Pacific Standard Time)