user823527 user823527 - 24 days ago 7
Javascript Question

datepicker date off by one day

The date returned by date picker is off by one day. Is it a problem in my code or is it a bug?

The date sent to date_picker is 2012-03-21. The date returned by datepicker is Tue Mar 20 2012.

var end_date = end_calendar.getFormatedDate("%Y-%m-%d");
end_date = $.datepicker.formatDate('D M dd yy', new Date(end_date));

Answer

Seems to be a bug. If the string sent to Date() is formatted as 2012/03/21 instead of 2012-03-21. The date seems right.

Comments