[SERVER-26977] Month and year not showing correctly Created: 10/Nov/16  Updated: 14/Nov/16  Resolved: 14/Nov/16

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: guru rajan Assignee: Kelsey Schubert
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

> var mydate1 = new Date()
> var mydate2 = ISODate()
> mydate1.toString()
Thu Nov 10 2016 02:45:10 GMT-0500 (EST)
> mydate2.toString()
Thu Nov 10 2016 02:45:14 GMT-0500 (EST)
----------------------------------------------------------------------------------------------------
 
> mydate1.getMonth()
10
> mydate2.getMonth()
10
> mydate1.getYear()
116

All the values shown above are wrong, Month should be 11 and year should be 2016



 Comments   
Comment by Kelsey Schubert [ 14/Nov/16 ]

Hi guruskec@gmail.com,

Thanks for your report. This is expected behavior. Please review the documentation around JavaScript Date Object Methods. Specifically, please note that getMonth() returns 0-11, and getYear() has been deprecated. I believe getFullYear() will provide the results that you expect.

Please note that SERVER project is for reporting bugs or feature suggestions for the MongoDB server. For MongoDB-related support discussion please post on the mongodb-users group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group.

Kind regards,
Thomas

Generated at Thu Feb 08 04:13:46 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.