javascript 如何在timepicker中设置最小和最大时间?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29272934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:19:15  来源:igfitidea点击:

How to set minimum and maximum time in timepicker?

javascriptjqueryjquery-uidatetimepicker

提问by user1692333

I'm using time pickerto 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 ?

如何从中正确创建日期并将限制附加到已初始化的时间选择器?

回答by Bellash

    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)
      });

回答by Irvin Dominin

I think you have to set these options:

我认为你必须设置这些选项:

hourMin

小时分钟

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

默认值:0 - 所有日期允许的最小小时数。

minuteMin

分钟

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

默认值:0 - 所有日期允许的最小分钟数。

secondMin

第二分钟

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

默认值:0 - 所有日期允许的最小秒数。

millisecMin

毫秒最小

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

默认值:0 - 所有日期允许的最小毫秒数。

microsecMin

微秒分钟

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

默认值:0 - 所有日期允许的最小微秒。

hourMax

最大小时数

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

默认值:23 - 所有日期允许的最大小时数。

minuteMax

分钟最大值

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

默认值:59 - 所有日期允许的最大分钟数。

secondMax

第二个最大值

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

默认值:59 - 所有日期允许的最大秒数。

millisecMax

毫秒最大值

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

默认值:999 - 所有日期允许的最大毫秒数。

microsecMax

微秒最大值

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

默认值:999 - 所有日期允许的最大微秒。

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

参考:http: //trentrichardson.com/examples/timepicker/--> 时间字段选项