Closed
Bug 175253
Opened 23 years ago
Closed 21 years ago
Date.getYear() gives the wrong result
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
People
(Reporter: wolf550e, Assigned: rogerl)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2a) Gecko/20020910
I get a wrong year value for the current date. Month and day are correct though,
so something is wrong with the year function and not with the time on my PC.
Reproducible: Always
Steps to Reproduce:
<script type="text/javascript" language="javascript">
var time=new Date();
var y = time.getYear();
var m = time.getMonth()+1;
var d = time.getDate();
document.write(y+'/'+m+'/'+d);
</script>
Actual Results:
102/10/18
Expected Results:
2002/10/18
Other browsers give correct and expected results, so it's not my code...
Maybe it is something in my system, but what can it be?
Upgraded to Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.2b)
Gecko/20021016, and it's still there.
Comment 2•23 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();
Comment 3•23 years ago
|
||
*** This bug has been marked as a duplicate of 100123 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago
Resolution: --- → DUPLICATE
Comment 4•23 years ago
|
||
Marking Verified Duplicate.
Also see these bugs, where this was discussed in more detail. In particular,
the history of how Netscape and IE came to differ on the getYear() method.
bug 22964
bug 45764
As José says, the method to use is getFullYear() instead -
Status: RESOLVED → VERIFIED
Summary: Date getYear wrong result → Date.getYear() gives the wrong result
Updated•21 years ago
|
Status: VERIFIED → UNCONFIRMED
Resolution: DUPLICATE → ---
Comment 5•21 years ago
|
||
*** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago → 21 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•