当输入框获得焦点时,调用datetimepicker。
$('#example_1').datetimepicker();
如果只需要显示时间,则:
$('#example_2').timepicker();
定义时间格式:
$('#example_3').datetimepicker({
showSecond: true,
showMillisec: true,
timeFormat: 'hh:mm:ss:l'
});
默认时间:
$('#example_6').datetimepicker({ numberOfMonths: 2, minDate: 0, maxDate: 30 });
显示时间标尺:
$('#example_7').timepicker({ hourGrid: 4, minuteGrid: 10 });
获取和设置时间:
var ex8 = $('#example_8'); ex8.datetimepicker(); $('#example_8_set_btn').click(function(){ ex8.datetimepicker('setDate', (new Date()) ); }); $('#example_8_get_btn').click(function(){ alert(ex8.datetimepicker('getDate')); });