datepicker cut off time TEST #2
by John Doe
HTML
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/mint-choc/jquery-ui.css">
<script src="https://rawgit.com/eu81273/jsfiddle-console/master/console.js"></script>
<script src="https://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data.min.js"></script>
<h1>
sol use http://phpfiddle.org/# as it uses servertime instead
</h1>
<div class="booking-date">
<p>
<label for="date">Select booking date below:</label>
<input id="date" type="text" name="properties[delivery-date]" readonly="readonly" style="background:white; width:30%" class="required" data-error="Please choose a delivery date." />
</p>
<div id="log"></div>
</div>
JavaScript
jQuery.noConflict();
var startDate, endDate, dateRange = [];
jQuery(".form1submit #submit1").hide();
jQuery(document).ready(function() {
// reset values on page reload
jQuery(window).bind("pageshow", function () {
jQuery("#pax").val('');
//this only disables after dom loaded
jQuery(".ui-datepicker-trigger").prop("disabled", true).removeClass("allow").addClass("disabled");
});
//[***********amitcoder ******************
jQuery('#pax').on('change', function () {
var tDate = jQuery('#tdate').val();
if (tDate != '') {
var date = tDate;
var d = new Date(date.split("-").reverse().join("-"));
var dd = d.getDate();
var mm = d.getMonth() + 1;
var yy = d.getFullYear();
var tDate = yy + "-" + mm + "-" + dd;
get_seats(jQuery("#choosetour").val(), tDate, jQuery("#seats_").val(), jQuery(this).val());
}
});
//*****end amitcoder******]
// add datepicker
jQuery("#tdate").datepicker({
minDate: checkBeforeBook(), //see scripts below
//minDate: 1, //see scripts below
maxDate: '+18m',
dateFormat: 'dd-mm-yy',
numberOfMonths: 1,
showOn: "both",
buttonImage: "<?php echo FULL_BOOKING_ENGINE_PATH ?>/images/cal.gif",
buttonText: "Choose Date",
showButtonPanel: true
});
/*========== Sol DATEPICKER checkbeforebook - check time - add cutoff ==========*/
// if time after 10pm, close next day booking
function checkBeforeBook(nextDayBook){
// tour booking for following day starts 10am and ends 10pm
// note: use 24hr time
var startTime = '00:00 AM';
var endTime = '22:00 PM'; // cut off time
var curr_time = getvaltime();
if (get24Hr(curr_time) > get24Hr(startTime) && get24Hr(curr_time) < get24Hr(endTime)) {
// next day book is available
console.log("start time :"+get24Hr(startTime) );
...