最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to set minimum and maximum time in timepicker? - Stack Overflow

programmeradmin3浏览0评论

I'm using time picker to select only time in my app. The problem is that I need to set min and max time limits from the string. For example I have:

var min = '10:15:12';
var max = '19:15:12';

How to properly create date from it and append limits to already initialized time picker ?

I'm using time picker to select only time in my app. The problem is that I need to set min and max time limits from the string. For example I have:

var min = '10:15:12';
var max = '19:15:12';

How to properly create date from it and append limits to already initialized time picker ?

Share Improve this question asked Mar 26, 2015 at 7:21 user1692333user1692333 2,5976 gold badges35 silver badges66 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 2
    jQuery('#picker').timepicker({min: '8:00 am', max: '8:00 pm'})

or

   var picker=jQuery('#picker');
    var min = '10:15:12 am';
    var max = '07:15:12 pm';
    picker.timepicker('option','min',min);
    picker.timepicker('option','max',max);

you have another example:

  $('#picker').datetimepicker({
        minDate: new Date(2010, 11, 20, 8, 30),
        maxDate: new Date(2010, 11, 31, 19, 30)
      });

I think you have to set these options:

hourMin

Default: 0 - The minimum hour allowed for all dates.

minuteMin

Default: 0 - The minimum minute allowed for all dates.

secondMin

Default: 0 - The minimum second allowed for all dates.

millisecMin

Default: 0 - The minimum millisecond allowed for all dates.

microsecMin

Default: 0 - The minimum microsecond allowed for all dates.

hourMax

Default: 23 - The maximum hour allowed for all dates.

minuteMax

Default: 59 - The maximum minute allowed for all dates.

secondMax

Default: 59 - The maximum second allowed for all dates.

millisecMax

Default: 999 - The maximum millisecond allowed for all dates.

microsecMax

Default: 999 - The maximum microsecond allowed for all dates.

Ref: http://trentrichardson./examples/timepicker/ --> Time Field Options

发布评论

评论列表(0)

  1. 暂无评论