This is because JavaScript is expecting a certain amount of characters in the date string.
You have two formats here:
(YYYY-MM-DD)
and
(YYYY-MM-D)
I am surprised that the second is returning anything at all, as it doesn't seem to fit any valid JavaScript Date String format. If it is returning as you say it is, then JavaScript is likely interpreting it as something other than Years, Months and Days.