Input: new Date("2013-03-28")
Output: Wed Mar 27 2013 17:00:00 GMT-0700 (PDT)
How do I get 28 instead of 27. Is this a javascript default issue?
Input: new Date("2013-03-28")
Output: Wed Mar 27 2013 17:00:00 GMT-0700 (PDT)
How do I get 28 instead of 27. Is this a javascript default issue?
When using ISO-formatted dates, either all or in-part, the timezone may be assumed to be UTC.
console.log(new Date("2013-03-28").toUTCString());
// "Thu, 28 Mar 2013 00:00:00 GMT"
To create the date in local time, you can use a different overload of the constructor (note that month
is 0-indexed, so 2
is March):
console.log(new Date(2013, 2, 28).toString());
// "Thu Mar 28 2013 00:00:00 GMT-0700 (...)"