hi,
I'm using jquery datetimepicker.
I don't want to allow user to select any past date other than current or future date.
I have achieved above functionality. All, i'm facing problem is with time.
I don't want to allow user to select any past time other than current or future time, i.e. if current time is 1:00 pm, user can't select past time to 1:00 pm
How can I achieve this?
What I have tried:
function getCurrentTime(date) {
var hours = date.getHours(),
minutes = date.getMinutes(),
ampm = hours >= 12 ? 'pm' : 'am';
hours = hours % 12;
hours = hours ? hours : 12; // the hour '0' should be '12'
minutes = minutes < 10 ? '0'+minutes : minutes;
return hours + ':' + minutes + ' ' + ampm;
}
var time = new Date().getTime();
var currentdate = new Date(time);
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() ;
//var time = currentdate.getHours() + ":" + currentdate.getMinutes();
$("#myDate").datetimepicker({
dayOfWeekStart: 1,
minDate: 0,
minTime: getCurrentTime(new Date()),
setDate:currentdate,
format: 'd/m/Y H:i',
formatTime: 'H:i',
formatDate: 'd/m/Y',
ampm: true,
step: workingHrSlot
//onChangeDateTime: logic,
//onShow: logic
});