description of "year" parameter in the JavaScript Date constructor documentation seems incorrect

RESOLVED FIXED

Status

Developer Documentation
JavaScript
P5
normal
RESOLVED FIXED
4 years ago
4 years ago

People

(Reporter: Fran Wahl, Assigned: David Bruant)

Tracking

Details

(Whiteboard: c=JavaScript u=webdev p=0, URL)

Attachments

(1 attachment)

(Reporter)

Description

4 years ago
:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: 26 Branch
 Technical Contact: 

:: Details

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

States under the year parameter:

year
Integer value representing the year. The year must always be provided in full (e.g. 98 is treated as 98, not 1998).

However, that does not seem correct:

The description of the constructor is:
new Date(year, month [, day, hour, minute, second, millisecond]);

When creating a date like this:   
new Date(98, 1, 1) 

The result is Date {Sun Feb 01 1998 00:00:00 GMT+0000 (GMT Standard Time)}

The year displayed is 1998 not 98, which seems to be the opposite of what the parameter description states.
(Reporter)

Updated

4 years ago
Summary: description of "year" parameter in the JavaScript Date constrcutor documentation seems incorrect → description of "year" parameter in the JavaScript Date constructor documentation seems incorrect
(Reporter)

Comment 1

4 years ago
Created attachment 8361796 [details]
JavaScript Date Object Construction results

Added a screenshot showing the results of Date object creation when using the Date constructor new Date(year, month [, day, hour, minute, second, millisecond]);
Thanks for reporting this. I updated the parameter description and added a small example:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Two%20digit%20years

Feel free to add more details or review these changes as the Mozilla Developer Network is a community driven wiki where everyone is welcome to share knowledge :-)
Status: UNCONFIRMED → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.