[英]How do I restrict dates on datepicker after a certain time?
At the moment I have this code here: 目前我在这里有这个代码:
<script type="text/javascript" src="catalog/view/javascript/jquery/ui/jquery-ui-timepicker-addon.js"></script>
<script type="text/javascript"><!--
if ($.browser.msie && $.browser.version == 6) {
$('.date, .datetime, .time').bgIframe();
}
$('.date').datepicker({dateFormat: 'D M dd, yy', minDate:2, beforeShowDay: $.datepicker.noWeekends});
$('.datetime').datetimepicker({
dateFormat: 'yy-mm-dd',
timeFormat: 'h:m'
});
$('.time').timepicker({timeFormat: 'h:m'});
//--></script>
It works great by I have one thing I would like to add to it. 它有用,我有一件事我想添加它。
I use the datepicker so my customers can choose a date when they can pick up an item. 我使用日期选择器,以便我的客户可以选择他们可以提取物品的日期。
I would like it to blank out the the next two days after it reaches 5.30pm EST. 我想在美国东部时间下午5点30分后的两天内将其删除。
So at 1pm on Monday I can only select Wednesday onwards. 所以星期一下午1点我只能选择星期三。 If it is 6pm Monday I can only order Thursday onwards.
如果是星期一下午6点,我只能在周四开始订购。
Does anyone know how to do this? 有谁知道如何做到这一点? I couldn't quite figure it out from the API website.
我无法从API网站上找到它。
Many Thanks 非常感谢
Peter 彼得
per the docs: http://jqueryui.com/datepicker/#min-max 根据文档: http : //jqueryui.com/datepicker/#min-max
you can set minDate: 2
depending on what time it is now. 您可以根据现在的时间设置
minDate: 2
。
var min = 1;
var currentTime = new Date();
if (currentTime.getHours() >=17 && currentTime.getMinutes() >=30){
min = 2;
}
then pass min
into minDate
. 然后将
min
传递给minDate
。
as ahren pointed out, though, this will be the user's time, not yours. 正如阿伦指出的那样,这将是用户的时间,而不是你的。 If you want to find the timezone and adjust from there you can use
getTimeZoneOffset
http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp 如果你想找到时区并从那里调整你可以使用
getTimeZoneOffset
http://www.w3schools.com/jsref/jsref_gettimezoneoffset.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.