Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aatronco/2be6ffd7ab7b8d551a70542e20872874 to your computer and use it in GitHub Desktop.
Save aatronco/2be6ffd7ab7b8d551a70542e20872874 to your computer and use it in GitHub Desktop.
var d = new Date()
var nDate = d.getTime() + 24 * 60 * 60 * 1000 ;
var start_date = new Date(nDate).toJSON().slice(0,10);
var min_hour = new Date(nDate).toJSON().slice(11,13);
// Cuando selecciona la fecha evalua si es menos de 24 horas hasta las 00:00, si esto ocurre deshabilita las horas que no corresponden
$("#checkout").change(function(){
var parts = $("#order_other_fecha_del_despacho").val().split('-');
var mydate = new Date(parseInt(parts[0]), parseInt(parts[1] - 1), parseInt(parts[2]));
var dif = mydate.getTime() - d.getTime()
if(dif < 86400000){
$("#order_other_hora_del_despacho").children("option").filter(function() {
return parseInt(this.value.slice(0,2)) < parseInt(min_hour) -3;
}).prop("disabled", true);
}else{
$("#order_other_hora_del_despacho").children("option").filter(function() {
return true;
}).prop("disabled", false);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment