nerd.post nerd.post - 6 months ago 23
Javascript Question

Timepicker Javascript displays time in incorrect way

I have a timepicker div tag in my HTML as :

<input class="timepicker" name="timepicker" id="from-timepicker"/>

The respective Javascript code is :

$('#from-timepicker').timepicker({
timeFormat: 'HH:mm',
// year, month, day and seconds are not important
minTime: new Date(0, 0, 0, 8, 0, 0),
maxTime: new Date(0, 0, 0, 15, 0, 0),
// time entries start being generated at 6AM but the plugin
// shows only those within the [minTime, maxTime] interval
startHour: 6,
// the value of the first item in the dropdown, when the input
// field is empty. This overrides the startHour and startMinute
// options
startTime: new Date(0, 0, 0, 8, 20, 0),
// items in the dropdown are separated by at interval minutes
interval: 10
});


On the UI, I see time as :

0808:mm
I need it in 08:08 (hh:mm) format.


Any idea where am I going wrong?

Answer

timepicker format: 'timeFormat': 'h:i'

timepicker.jquery uses the time portion of php.

Comments