Skip to content

Issue with "Date.prototype.setDate()": month calculation based on local time, not UTC #2833

@terrymorse58

Description

@terrymorse58

MDN URL: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/setDate

The setDate documentation doesn't state that the month determination is performed in local time, rather than UTC.

Please add a line somewhere that states that the calculation is based on local time. The only way to know from the doc is to click through on the spec.

Specific section or headline? No.

Expected to see the calculation based on UTC (which it is not)

Tested with the following in UTC-8 timezone

const myDate = new Date('2021-01-01T00:00:00.000Z');
myDate.setDate(2);
console.log(myDate.toISOString()); // '2020-12-03T00:00:00.000Z'
MDN Content page report details

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions