Your third example is the only one that is actually explained by the spec. When you call the Date
constructor with a single argument, this is what happens (where v
is the string passed to the constructor):
Parse v
as a date, in exactly the same manner as for the parse
method (15.9.4.2); let V
be the time value for this date.
The parse
method will attempt to parse the string (emphasis added):
The String may be interpreted as a local time, a UTC time, or a time in some other time zone, depending on the contents of the String. The function first attempts to parse the format of the String according to the rules called out in Date Time String Format (15.9.1.15).
If the String does not conform to that format the function may fall back to any implementation-specific heuristics or implementation-specific date formats.
And the "Date Time String Format" is YYYY-MM-DDTHH:mm:ss.sssZ
, and also defines a shorter version of the form YYYY-MM-DD
, which is what you use in your third example.
For the other examples, the parse will fail and the behaviour is implementation-defined.