The input value is being interpreted correctly. ECMAScript 2015 (ES6) section 20.3.1.16 states:
If the time zone offset is absent, the date-time is interpreted as a local time.
This aligns with the ISO-8601 standard as well.
In previous versions of ECMAScript, UTC was assumed when no offset was provided. That goes against ISO-8601, and was implemented inconsistently across various environments.
If you want the input to be interpreted as UTC, then you should provide an offset, either +00:00
, or Z
as part of the input string.
However, if you are talking about how a Date
object should be displayed when logged to the debug console, that is not defined in the spec. In some environments, you will see the output of date.toString()
, which shows the local date and time in a non-standard format, and in other environments (such as FireFox) you will see the output of date.toISOString()
, which shows the UTC date and time in ISO-8601 format.
There's no spec about which to show, so either would be valid. If you want to see specific output, don't just log a Date
object, call a function on the object that returns a string and log that instead.