Actually I tried to set a jquery datepicker with a determinated date but when I create a new date for set the widget, javascript throw me one day minus
Code:
new Date('2016-04-14')
Result:
Wed Apr 13 2016 17:00:00 GMT-0700 (US Mountain Standard Time)
jsfiddle
You should read the fine manual
Note: parsing of date strings with the
Dateconstructor (andDate.parse, they are equivalent) is strongly discouraged due to browser differences and inconsistencies.
You should probably go with new Date(2016, 3, 14) (3 because the month integer is zero-based). This will create a date in your timezone at midnight, April 14.
To get the UTC(GMT) time use .toUTCString() instead of the default .toString().
If you want to create local time midnight date from string, use iso8601 like 2016-04-01T00:00:00-07:00. Note the timezone offset.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With