I need to generate a javascript Date
from a UTC date string with the format YYYY-MM-DD
. Here is an example:
var date = new Date('2018-01-31');
The date this creates is:
Tue Jan 30 2018 19:00:00 GMT-0500 (Eastern Standard Time)
Given the time zone offset, the date is yesterday.
How can I create a javascript Date that assumes the timeless input is UTC?