#764·Pikaday

setDate subtracts a day when setting the date

Author: ghostCreated Jan 24, 2018Updated Oct 27, 2023

While writing some test code today, I discovered that setDate actually sets the date to the previous day.

    // Pikaday setDate has an off by one error when setting the date.
    $('#datepicker').pikaday('setDate', '2017-01-01');
    // So we need to check the day before for formatting.
    expect($('#datepicker').val()).toEqual('12/31/2016');

I have an input field at #datepicker and the above code shows what the date is set to. This is a Jasmine test, but I observed the same behavior in Chrome.

This bug was also reported in #599 .