Closed Bug 175253 Opened 23 years ago Closed 21 years ago

Date.getYear() gives the wrong result

Categories

(Core :: JavaScript Engine, defect)

x86
Windows XP
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 22964

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.
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: 23 years ago
Resolution: --- → DUPLICATE
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
Status: VERIFIED → UNCONFIRMED
Resolution: DUPLICATE → ---
*** This bug has been marked as a duplicate of 22964 ***
Status: UNCONFIRMED → RESOLVED
Closed: 23 years ago21 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.