Default Year In Date If Datestring Does Not Have Year Part
I was trying to check what values would return if partial values are sent. I was expecting it to be 28th Nov., 2016(current year), but it returns 28th Nov., 2001. So the question
Solution 1:
2001 is not consider as default year.
This is a Chrome issue, if you run the same code with Firefox you get Invalid Date
.
Solution 2:
The language specification only includes rules for parsing ISO 8601 formatted strings. Parsing of any other format is implementation dependent (noting that the Date constructor and Date.parse are equivalent for parsing).
So given "11/28" is not a valid ISO 8601 string, the implementation is free to apply any heuristics it likes. Any result, including an invalid date, should be expected and consistency between implementations should not.
Post a Comment for "Default Year In Date If Datestring Does Not Have Year Part"