Description of the Issue and Steps to Reproduce:
- Receive user input as 3/3
var response
- Parse into a date variable
var date = moment(new Date(response))
- Doing a console.log of date gives
moment("2001-03-03T00:00:00.000")
The year defaults to 2001. Since the user may input the date in their own format, I didn't want to add in a format as I wouldn't know what format they might want to enter.
After looking around, I found some Moment github issues on this (#635, #912) which mentioned that the issue was resolved, but I am still getting the default year of 2001.
I also found a suggestion to set the year as this year if left unspecified:
if (date.year() === 2001) {
date.year() = moment().year();
}
This works, but feels like a dirty solution. Any ideas what I can do instead?
Thanks in advance!
Current Environment
- Node.js
v8.9.4
- Moment.js
v2.20.1
- VS code
v1.19.3
- MS Bot SDK
v3.14.0
p/s Still pretty new to the stackoverflow/ github issues, and not to sure where I should have posted instead. Please let me know if you need more information!