trentrichardson / jQuery-Timepicker-Addon

Adds a timepicker to jQueryUI Datepicker
http://trentrichardson.com/examples/timepicker/
MIT License
2.66k stars 1.05k forks source link

Time set as default, but not populating in 'getDate' #915

Closed sdillinger closed 7 years ago

sdillinger commented 7 years ago

When I set a default time (hour, minute) in the constructor, and then use getDate, the field is empty in the return string.

If I select an hour using the slider and then use getDate the field is populated.

Examples:

var now = new Date(Date.now());
    now.setHours(now.getHours()+2);
    var now_plus_2 = now;

    var end_date = new Date();
    end_date.setDate(end_date.getDate() + 14);

    $('#ag-timepicker').datetimepicker({
        timeFormat: 'hh tt',
        oneLine: true,
        minDateTime: now_plus_2,
        maxDateTime: end_date,
        hourMin: 8,
        hourMax: 23,
        hour: now_plus_2.getHours(),    <----------------------
        minute: '00',   <-----------------------------------------
        closeText: 'Done',
        showButtonPanel: false,
        timeText: 'Completed by:'

    });

$('#ag-timepicker').datetimepicker('getDate');

jquery-ui-timepicker-addon.js:2261 Error parsing the date/time string: Wrong time format
date/time string = 03/27/2017 
timeFormat = hh tt
dateFormat = mm/dd/yy
Mon Mar 27 2017 00:00:00 GMT-0500 (Central Daylight Time)

Example after using slider to select 7pm

$('#ag-timepicker').datetimepicker('getDate')
Mon Mar 27 2017 19:00:00 GMT-0500 (Central Daylight Time)

Thanks for any assistance you can provide.