Putting minutes into working time

Asked

Viewed 31 times

0

I have the following code, where determines the time of operation of Delivery. Follow code:

function delivery(){
  var cep1 = document.getElementById("cep1").value;
  var cep2 = document.getElementById("cep2").value;
  var cep = cep1 + "-" + cep2;
  var data = new Date();
  var mes = data.getMonth() + 1; 
  var diaMes = data.getDate();
  var hoje = diaMes + "/" + mes;
  var diaSemana = data.getDay();
  var hora = data.getHours();           // 0-23
  if(feriados.indexOf(hoje) != -1 || diaSemana == 0 || diaSemana == 6){
      $("#data").venobox().trigger('click');
  }else if(hora < 7 || hora > 16){
      $("#hora").venobox().trigger('click');
  }else if(ceps.indexOf(cep) == -1){
      $("#cep").venobox().trigger('click');
  }else{
      if (diaSemana == 1){
          location.assign("http://bardananatural.com.br/pedido_online/segunda/index_segunda.php");
      } else if (diaSemana == 2){
          location.assign("http://bardananatural.com.br/pedido_online/terca/index_terca.php");
      } else if (diaSemana == 3){
          location.assign("http://bardananatural.com.br/pedido_online/quarta/index_quat.php");
      } else if (diaSemana == 4){
          location.assign("http://bardananatural.com.br/pedido_online/quinta/index_quin.php");
      } else if (diaSemana == 5){
          location.assign("http://bardananatural.com.br/pedido_online/sexta/index_sext.php");
      } else {
          $("#hora").venobox().trigger('click');
      };
  };
 }

What I do not know and need and put the time limit from 16h (today) to 15:30, ie, put the minutes that today does not exist. I know the code part is this:

var hora = data.getHours();         // 0-23
  if(feriados.indexOf(hoje) != -1 || diaSemana == 0 || diaSemana == 6){
      $("#data").venobox().trigger('click');
  }else if(hora < 7 || hora > 16){
      $("#hora").venobox().trigger('click');

I just don’t know how to do it! I appreciate everyone’s help!

  • var minute = date.getMinutes(); So you can manipulate your code minutes, now I don’t know exactly what makes the venobox click as soon as possible I search to contribute more.

1 answer

0

I think you can settle this quietly with the library Moment.js:

Example:

moment().format('MM DD YYYY, h:mm:ss'); // 09 29 2017, 3:07:08
  • I appreciate the attention, but I’m a layman, I don’t understand how to use that code in my!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.