JS: fixing date issue with datepicker