January is month 0. December is month 11.
So this should work:
var d = new Date(2016, 11, 17, 0, 0, 0, 0);
Also, you can just simply do:
var d = new Date(2016, 11, 17);
Answer from Dean Coakley on Stack Overflow Top answer 1 of 2
121
January is month 0. December is month 11.
So this should work:
var d = new Date(2016, 11, 17, 0, 0, 0, 0);
Also, you can just simply do:
var d = new Date(2016, 11, 17);
2 of 2
67
According to MDN - Date:
month
Integer value representing the month, beginning with 0 for January to 11 for December.
You should subtract 1 from your month:
const d = new Date(2016, 11, 17, 0, 0, 0, 0);
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date
Date - JavaScript | MDN
Returns the day of the month (1 – 31) for the specified date according to local time. ... Returns the day of the week (0 – 6) for the specified date according to local time. ... Returns the year (4 digits for 4-digit years) of the specified date according to local time.
Videos
07:37
JavaScript Date Object Tutorial (2025): Format, Parse & Fix Timezones ...
Get the Day of the Year of a Date in JavaScript - YouTube
Create a Year Day prototype for Date in JavaScript - YouTube
08:02
Learn JavaScript DATE objects in 8 minutes! 📅 - YouTube
W3Schools
w3schools.com › js › js_dates.asp
JavaScript Dates
const d = new Date(2018, 11, 24, 10, 33, 30, 0); Try it Yourself » ... January = 0. December = 11. Specifying a month higher than 11, will not result in an error but add the overflow to the next year: ... Specifying a day higher than max, will not result in an error but add the overflow to the next month: ... You cannot omit month. If you supply only one parameter it will be treated as milliseconds. ... JavaScript stores dates as number of milliseconds since January 01, 1970.
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › Date
Date() constructor - JavaScript | MDN
For example, new Date(2020, 5, 0) will return May 31st, 2020. ... Integer value representing the year. Values from 0 to 99 map to the years 1900 to 1999. All other values are the actual year. See the example. ... Integer value representing the month, beginning with 0 for January to 11 for December.
Top answer 1 of 16
615
const dateObj = new Date();
const month = dateObj.getUTCMonth() + 1; // months from 1-12
const day = dateObj.getUTCDate();
const year = dateObj.getUTCFullYear();
const newDate = year + "/" + month + "/" + day;
// Using template literals:
const newDate = `${year}/${month}/${day}`;
// Using padded values, so that 2023/1/7 becomes 2023/01/07
const pMonth = month.toString().padStart(2,"0");
const pDay = day.toString().padStart(2,"0");
const newPaddedDate = `${year}/${pMonth}/${pDay}`;
or you can set new date and give the above values
2 of 16
208
new Date().toISOString()
"2016-02-18T23:59:48.039Z"
new Date().toISOString().split('T')[0];
"2016-02-18"
new Date().toISOString().replace('-', '/').split('T')[0].replace('-', '/');
"2016/02/18"
new Date().toLocaleString().split(',')[0]
"2/18/2016"
W3Schools
w3schools.com › js › js_date_methods.asp
JavaScript Date Methods
The getFullYear() method returns ... code might use the non-standard method getYear(). ... The getMonth() method returns the month of a date as a number (0-11)....
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › setMonth
Date.prototype.setMonth() - JavaScript | MDN
The setMonth() method of Date instances changes the month and/or day of the month for this date according to local time. const event = new Date("August 19, 1975 23:15:30"); event.setMonth(3); console.log(event.getMonth()); // Expected output: 3 console.log(event); // Expected output: "Sat Apr ...
Mozilla
developer.mozilla.org › en-US › docs › Web › JavaScript › Guide › Representing_dates_times
Representing dates & times - JavaScript | MDN
The exact forms supported differ among engines, but the following form is always supported: YYYY-MM-DDTHH:mm:ss.sssZ. For example, xmas95 = new Date("1995-12-25"). If you omit hours, minutes, or seconds, the value will be set to zero. A set of integer values for year, month, and day.
Moment.js
momentjs.com › docs
Moment.js | Docs
Get + Set Millisecond Second Minute Hour Date of Month Day of Week Day of Week (Locale Aware) ISO Day of Week Day of Year Week of Year Week of Year (ISO) Month Quarter Year Week Year Week Year (ISO) Weeks In Year Weeks In Year (ISO) Get Set Maximum Minimum · Manipulate Add Subtract Start of Time End of Time Maximum Minimum Local UTC UTC offset Time zone Offset · Display Format Time from now Time from X Time to now Time to X Calendar Time Difference Unix Timestamp (milliseconds) Unix Timestamp (seconds) Days in Month As Javascript Date As Array As JSON As ISO 8601 String As Object As String Inspect
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-get-the-first-day-of-the-year-in-javascript
How to get the first day of the year in JavaScript ? - GeeksforGeeks
July 12, 2025 - Example: This example uses the ... = new Date(); console.log("Today = " + date); // Use Date(year, month, day) function console.log(new Date(date.getFullYear(), 0, 1));...
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › setFullYear
Date.prototype.setFullYear() - JavaScript | MDN
The setFullYear() method of Date instances changes the year, month, and/or day of month for this date according to local time. const event = new Date("August 19, 1975 23:15:30"); event.setFullYear(1969); console.log(event.getFullYear()); // Expected output: 1969 event.setFullYear(0); ...
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Date › getMonth
Date.prototype.getMonth() - JavaScript | MDN
The getMonth() method of Date instances returns the month for this date according to local time, as a zero-based value (where zero indicates the first month of the year). const moonLanding = new Date("July 20, 69 00:20:18"); console.log(moonLanding.getMonth()); // (January gives 0) // Expected ...
Top answer 1 of 8
302
var d = new Date(2011,10,30);
as months are indexed from 0 in js.
2 of 8
109
You definitely want to use the second expression since months in JS are enumerated from 0.
Also you may use Date.parse method, but it uses different date format:
var timestamp = Date.parse("11/30/2011");
var dateObject = new Date(timestamp);