问题
I'm in the Azores islands and yesterday (30 October 2016) the timezone has changed from GMT+0000 (AZOST) to GMT-0100 (AZOT).
Now new Date('2016-10-31') is returning Sun Oct 30 2016 23:00:00 GMT-0100 (AZOT):
Is this the correct behaviour from the JavaScript Date object? I was expecting the output to be Mon Oct 31 2016...
回答1:
From this documentation (emphasis mine):
Note: parsing of date strings with the Date constructor (and Date.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies. Support for RFC 2822 format strings is by convention only. Support for ISO 8601 formats differs in that date-only strings (e.g. "1970-01-01") are treated as UTC, not local.
来源:https://stackoverflow.com/questions/40342395/new-date2016-10-31-returning-sun-oct-30-2016