Closed
Bug 180587
Opened 22 years ago
Closed 20 years ago
getYear() function of date object in javascript returns year as 102 instead of 2002
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: bhavin_v, Assigned: rogerl)
Details
Attachments
(1 file)
535 bytes,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2b) Gecko/20021016
Build Identifier: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.2b) Gecko/20021016
If you create a Date object and the call the getYear() function (for getting the
current year), it returns 102 instead of 2002.
Looks like the Y2K bug, since javascript returns two digit year for years before
2000, eg: 1976 would show up as 76. However, post 1999, it should return 4 digit
year (it does in IE).
Reproducible: Always
Steps to Reproduce:
1. Cut-Paste the page provided in additional information and save it as an HTML
document.
2. Open it up in Mozilla and you will see 102, open it up in IE and you will see
2002
3.
Actual Results:
see 102 as year instead of 2002
Expected Results:
Shown year as 2002
<HEAD>
<SCRIPT language="JavaScript">
<!--
function JSClock() {
var time = new Date()
var month = time.getMonth()
var year = time.getYear()
var day = time.getDay()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
document.clockForm.digits.value = year
}
//-->
</SCRIPT>
</HEAD>
<BODY ONLOAD="JSClock()">
<FORM NAME="clockForm">
The current year is <INPUT TYPE="text" NAME="digits" SIZE=12 VALUE="">
</FORM>
</BODY>
Reporter | ||
Comment 1•22 years ago
|
||
Comment 2•22 years ago
|
||
This is INVALID, see:
http://developer.netscape.com/docs/manuals/communicator/jsref/core3.htm#1013157
To get the full year, use
var y = time.getFullYear();
*** This bug has been marked as a duplicate of 100123 ***
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago
Resolution: --- → DUPLICATE
Comment 4•22 years ago
|
||
Also see bug 45764 comment #4 for a history of how Mozilla/Netscape
came to differ from Microsoft IE on the getYear() method -
Reporter | ||
Comment 5•22 years ago
|
||
Thanks all! That help a lot!
Updated•20 years ago
|
Status: VERIFIED → UNCONFIRMED
Resolution: DUPLICATE → ---
Comment 6•20 years ago
|
||
*** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 22 years ago → 20 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•