Javascript creates a new date minus one day

Actually I tried setting a jquery datepicker with a specific date, but when I create a new date to set the widget, javascript throws me one day minus

the code:

new Date('2016-04-14')

Result:

Wed Apr 13 2016 17:00:00 GMT-0700 (US Mountain Standard Time)

jsfiddle

+4
source share
2 answers

You must read the exact manual.

Note: parsing date strings with a constructor Date(and Date.parsethey are equivalent) is very discouraged due to browser differences and inconsistencies.

, new Date(2016, 3, 14) (3, ). , 14 .

+4

UTC (GMT), .toUTCString() .toString().

, iso8601, 2016-04-01T00:00:00-07:00. .

+2

All Articles