[英]Specific Time interval by user
While using a start_time
and end_time
in an HTML file for django application.在 django 应用程序的 HTML 文件中使用start_time
和end_time
时。 I have used the time tag as follows:我使用的时间标签如下:
<div>Start Time <input type="time" min="" max="" id="" name="start_time"></div>
<div>End Time <input type="time" min="" max="" id="" name="end_time"></div>
But the constraint here is - the user will give the timings varying from 5:00 AM to 4:59 AM
.但这里的限制是- 用户将给出从5:00 AM to 4:59 AM
不等的时间。
So, can anyone suggest what values should we need to have as min and max for start_time
and end_time
in the tags.那么,任何人都可以建议我们需要在标签中为start_time
和end_time
哪些值作为最小值和最大值。 Any other workaround is also welcomed.也欢迎任何其他解决方法。
This is the problem you are likely to run into when you set constraints manually.这是您在手动设置约束时可能会遇到的问题。
Consider using a Bootstrap Time Picker, this way the constraints will be taken care of.考虑使用引导时间选择器,这样可以处理约束。
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <div class="col-md-6"> <div class="md-form md-outline input-with-post-icon timepicker" darktheme="true"> <input type="text" id="dark-version-example" class="form-control" placeholder="Select time"> <label for="dark-version-example">Dark version, 24 hours</label> <i class="fas fa-envelope input-prefix"></i> </div> </div> </div>
See the example from here从这里查看示例
If you wanted to define a shop that was open from 8:30 AM to 8:30 PM with a 30 minute for example, it would look as follows:例如,如果您想定义一家营业时间为 30 分钟的上午 8:30 到晚上 8:30 的商店,则如下所示:
$('.event_date').datetimepicker({
disabledTimeIntervals: [
[moment().hour(0).minutes(0), moment().hour(8).minutes(30)],
[moment().hour(20).minutes(30), moment().hour(24).minutes(0)]
]
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.