A quite simple question. I have three numbers, a year, a month and a day.
var year = parseInt($("#date_year").val()); var month = parseInt($("#date_month").val()) - 1; // to start from 0 var day = parseInt($("#date_day").val()); I want a proper Date object in JS initialized with these values. I tried this:
var date = new Date(year, month, day); However, it is behaving weirdly, a day is not correct and also the time is not 00:00:00, e.g. for values:
year: 1987 month: 9 day: 28 after printing date.toUTCString() I get:
Tue, 27 Oct 1987 23:00:00 GMT when I would expect:
Wed, 28 Oct 1987 00:00:00 GMT Can anyone please point out, what I am not understanding correctly?