如何在上午12点到12点30分之间设置分钟

时间:2017-05-26 06:08:32

标签: javascript

*如何设置小时为12:30 am *它只能工作到晚上11:30使用小时

  • 列出项目 如何设置上午12:30的小时它只能工作到晚上11:30使用小时< = 22 |分钟< = 30但是一旦我尝试做上午12点并在几分钟内没有显示

    
    
        var img2 = new Image();
        var now2 = new Date();
      
    
      var checkTime2 = function() {
    
      var timeDivBorder2 = document.getElementById('timeBorder2');
      var timeDiv2 = document.getElementById('timeDiv2');
      var timeDivBorderTaco2 = document.getElementById('timeBorderTaco2');
      var timeDivTaco2 = document.getElementById('timeDivTaco2');
      var timeDivBorderDine2 = document.getElementById('timeBorderDine2');
      var timeDivDine2 = document.getElementById('timeDivDine2');
      var timeDivBorderBreakfast2 = document.getElementById('timeBorderBreakfast2');
      var timeDivBreakfast2 = document.getElementById('timeDivBreakfast2');
      
    
    
      var today = weekday[now2.getDay()];
      var dayOfWeek = now2.getDay();
      var hour = now2.getHours();
      var minutes = now2.getMinutes();
    
      //add AM or PM
      var suffix = hour >= 12 ? "PM" : "AM";
    
    
      // add 0 to one digit minutes
      if (minutes < 10) {
        minutes = "0" + minutes
      };
    
      if ((dayOfWeek == 1 || dayOfWeek == 2 || dayOfWeek == 3 || dayOfWeek == 4 || dayOfWeek == 0 ) && hour >= 6 && hour <= 21) {
        hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
    	timeDivBorder2.className = 'openGreen';
    	timeDiv2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
        timeDiv2.className = 'open';
    	timeDivBorderTaco2.className = 'openGreen';
    	timeDivTaco2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivTaco2.className = 'open';
    	timeDivBorderDine2.className = 'openGreen';
    	timeDivDine2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivDine2.className = 'open';
    	timeDivBorderBreakfast2.className = 'openGreen';
    	timeDivBreakfast2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivBreakfast2.className = 'open';
    	img2.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
      }
    
      else if ((dayOfWeek == 5 || dayOfWeek == 6) && hour >= 9 && hour <= 23) {
        hour = ((hour + 11) % 12 + 1);
    	timeDivBorder2.className = 'openGreen';
    	timeDiv2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
        timeDiv2.className = 'open';
    	timeDivBorderTaco2.className = 'openGreen';
    	timeDivTaco2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivTaco2.className = 'open';
    	timeDivBorderDine2.className = 'openGreen';
    	timeDivDine2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivDine2.className = 'open';
    	timeDivBorderBreakfast2.className = 'openGreen';
    	timeDivBreakfast2.innerHTML = 'it\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>';
    	timeDivBreakfast2.className = 'open';
    	img2.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOn.gif';
      }
    
      else {
        if (hour == 0 || hour > 8) {
          hour = ((hour + 11) % 12 + 1); //i.e. show 1:15 instead of 13:15
        }
    	timeDivBorder2.className = 'closedRed';
    	timeDiv2.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>' ;
        timeDiv2.className = 'closed';
    	timeDivBorderTaco2.className = 'closedRed';
    	timeDivTaco2.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>' ;
        timeDivTaco2.className = 'closed';
    	timeDivBorderDine2.className = 'closedRed';
    	timeDivDine2.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>' ;
        timeDivDine2.className = 'closed';
    	timeDivBorderBreakfast2.className = 'closedRed';
    	timeDivBreakfast2.innerHTML = 'It\'s ' + today + ' ' + hour + ':' + minutes + suffix + '<br><center><img style="width:100%;top:0px;border-radius:10px;" src="'+img2.src+'" /></center>' ;
        timeDivBreakfast2.className = 'closed';
    	img2.src = 'http://www.weebly.com/editor/uploads/1/1/3/4/11341626/custom_themes/599346900698327146/files/Gifs/OpenLightOff.png';
      }
    };
    
    var weekday = new Array(7);
    weekday[0] = "Sunday";
    weekday[1] = "Monday";
    weekday[2] = "Tuesday";
    weekday[3] = "Wednesday";
    weekday[4] = "Thursday";
    weekday[5] = "Friday";
    weekday[6] = "Saturday";
    var currentDay2 = weekday[now2.getDay()];
    var currentDayID2 = "#" + currentDay2; //gets todays weekday and turns it into id
    $(currentDayID2).toggleClass("today"); //hightlights today in the view hours modal popup'
    
    setInterval(checkTime2, 1000);
    checkTime2();
    &#13;
    /*timee*/
    
    .timebox{
    	position:fixed;
    	display:block;
    	padding:0px;
    	top:10px;
    	right:10px;
    	z-index:1;
    }
    
    .open {
      color: #27ae60;
    
    }
    
    .openGreen {
      position:relative;
      box-shadow: 0px 0px 3px 4px #3DFF01;
      animation: Open 1s infinite;
    }
    @keyframes Open {
    	50%{box-shadow: 0px 0px 3px 4px #30cc00;}
    }
    
    .closed {
    
      color: rgba(231, 76, 60, 0.85);
    
    }
    
    .closedRed {
    position:relative;
    box-shadow: 0px 0px 3px 4px #FF0101;
    animation: close 1s infinite;
    }
    @keyframes close {
    	50%{box-shadow: 0px 0px 3px 4px #FF0101;}
    }
    
    [id^="timeBorder"] {
    	border-radius:20px;
    	margin-left:auto;
        margin-right:auto;
    	bottom:5px;
    	display:block;
    	position:relative;
    	padding:0px;
        width:185px;
    	height:185px;
    }
    
    * {
      margin: 0;
      padding: 0;
      font-family: 'Lato', sans-serif;
    }
    
    /*
     #timeDiv1, #timeDiv2, #timeDiv3,
     #timeDiv4, #timeDiv5, #timeDiv6,
     #timeDiv7, #timeDiv8, #timeDiv9,
     #timeDiv10, #timeDiv11, #timeDiv12,
     #timeDiv13, #timeDiv14, #timeDiv15,
     #timeDiv16, #timeDiv17, #timeDiv18,
     #timeDiv19, #timeDiv20, #timeDiv21,
     #timeDiv22, #timeDiv23, #timeDiv24,
     #timeDiv25, #timeDiv26, #timeDiv27,
     #timeDiv28, #timeDiv29, #timeDiv30,
     #timeDiv31, #timeDiv32, #timeDiv33,
     #timeDiv34, #timeDiv35, #timeDiv36,
     #timeDiv37, #timeDiv38, #timeDiv39,
     #timeDiv40, #timeDiv41,
     
     #timeDivTaco2,
     
      #timeDivDine2,
     
     #timeDivBreakfast2*/
     [id ^="timeDiv"]
     {
      font-size: .9em;
      text-transform: uppercase;
      text-align: center;
      position:static;
      width:185px;
      background: transparent;
      margin: 0 auto;
      top: 10px;
      border-radius: 3px;
     /* -webkit-box-shadow: 0 8px 16px -8px #adadad;
      -moz-box-shadow: 0 8px 16px -8px #adadad;
      box-shadow: 0 8px 16px -8px #adadad;*/
      display:block;
      vertical-align: top;
      font-weight: 600;
      background-color: rgb(0,0,0); /* Fallback color */
        background-color: rgba(0,0,0,0.5); /* Black w/ opacity */
    }
    
     /*
     .viewOpen1, .viewOpen2, .viewOpen3,
     .viewOpen4, .viewOpen5, .viewOpen6,
     .viewOpen7, .viewOpen8, .viewOpen9,
     .viewOpen10, .viewOpen11, .viewOpen12,
     .viewOpen13, .viewOpen14, .viewOpen15,
     .viewOpen16, .viewOpen17, .viewOpen18,
     .viewOpen19, .viewOpen20, .viewOpen21,
     .viewOpen22, .viewOpen23, .viewOpen24,
     .viewOpen25, .viewOpen26, .viewOpen27,
     .viewOpen28, .viewOpen29, .viewOpen30,
     .viewOpen31, .viewOpen32, .viewOpen33,
     .viewOpen34, .viewOpen35, .viewOpen36,
     .viewOpen37, .viewOpen38, .viewOpen39,
     .viewOpen40, .viewOpen41,
     
     .viewOpenTaco2,
     
     .viewOpenDine2,
     
     .viewOpenBreakfast2*/
     
    [class^="viewOpen"]
     {
      font-size: 15px;
      text-transform: uppercase;
      display:block;
      border: 2px solid rgba(70, 70, 70, 0.7);
      max-width: 100%;
      background: #fff;
      color: rgba(70, 70, 70, 0.8);
      margin: 0 auto;
      top:160px;
      padding: 10px;
      border-radius: 3px;
      -webkit-box-shadow: 0 8px 16px -8px #adadad;
      -moz-box-shadow: 0 8px 16px -8px #adadad;
      box-shadow: 0 8px 16px -8px #adadad;
      cursor: pointer;
      border:blue solid 1px;
      position:static;
    
    }
    
    /*
     .viewOpen1 i, .viewOpen2 i, .viewOpen3 i,
     .viewOpen4 i, .viewOpen5 i, .viewOpen6 i,
     .viewOpen7 i, .viewOpen8 i, .viewOpen9 i,
     .viewOpen10 i, .viewOpen11 i, .viewOpen12 i,
     .viewOpen13 i, .viewOpen14 i, .viewOpen15 i,
     .viewOpen16 i, .viewOpen17 i, .viewOpen18 i,
     .viewOpen19 i, .viewOpen20 i, .viewOpen21 i,
     .viewOpen22 i, .viewOpen23 i, .viewOpen24 i,
     .viewOpen25 i, .viewOpen26 i, .viewOpen27 i,
     .viewOpen28 i, .viewOpen29 i, .viewOpen30 i,
     .viewOpen31 i, .viewOpen32 i, .viewOpen33 i,
     .viewOpen34 i, .viewOpen35 i, .viewOpen36 i,
     .viewOpen37 i, .viewOpen38 i, .viewOpen39 i,
     .viewOpen40 i, .viewOpen41 i,
     
     .viewOpenTaco2 i,
     
     .viewOpenDine2 i,
     
     .viewOpenBreakfast2 i*/
     [class^="viewOpen"] i
     {
      color: rgba(70, 70, 70, 0.8);
    }
    
    
    
    
    
    .dateTime  {
      max-width: 320px;
      margin: 0 auto;
    }
    
    .day {
      display: inline-block;
      float: left;
    }
    
    .time {
      display: inline-block;
      float: right
    }
    
    .today {
      color: rgb(200, 85, 39);
      font-weight: 600;
    }
    
    
    /*
    @media all and (max-height: 420px) {
      #timeDiv1, .viewOpen1,
      #timeDiv6, .viewOpen6,
      #timeDiv31, .viewOpen31,
      #timeDiv32, .viewOpen32,
      #timeDiv33, .viewOpen33
      {
        top: 60%;
      }
    }
     view hours modal */
    
    @keyframes fade-in {
      0% {
        opacity: 0;
      }
      100% {
        opacity: 1;
      }
    }
     /*
     .modal-overlay1, .modal-overlay2, .modal-overlay3,
     .modal-overlay4, .modal-overlay5, .modal-overlay6,
     .modal-overlay7, .modal-overlay8, .modal-overlay9,
     .modal-overlay10, .modal-overlay11, .modal-overlay12,
     .modal-overlay13, .modal-overlay14, .modal-overlay15,
     .modal-overlay16, .modal-overlay17, .modal-overlay18,
     .modal-overlay19, .modal-overlay20, .modal-overlay21,
     .modal-overlay22, .modal-overlay23, .modal-overlay24,
     .modal-overlay25, .modal-overlay26, .modal-overlay27,
     .modal-overlay28, .modal-overlay29, .modal-overlay30,
     .modal-overlay31, .modal-overlay32, .modal-overlay33,
     .modal-overlay34, .modal-overlay35, .modal-overlay36,
     .modal-overlay37, .modal-overlay38, .modal-overlay39,
     .modal-overlay40, .modal-overlay41,
     
     .modal-overlayTaco2,
     
     .modal-overlayDine2,
     
     .modal-overlayBreakfast2
     */
    [class ^= "modal-overlay"]
     {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background-color: rgba(173, 173, 173, .3);
      display: none;
    }
    /*
     #modal-state1, #modal-state2, #modal-state3,
     #modal-state4, #modal-state5, #modal-state6,
     #modal-state7, #modal-state8, #modal-state9,
     #modal-state10, #modal-state11, #modal-state12,
     #modal-state13, #modal-state14, #modal-state15,
     #modal-state16, #modal-state17, #modal-state18,
     #modal-state19, #modal-state20, #modal-state21,
     #modal-state22, #modal-state23, #modal-state24,
     #modal-state25, #modal-state26, #modal-state27,
     #modal-state28, #modal-state29, #modal-state30,
     #modal-state31, #modal-state32, #modal-state33,
     #modal-state34, #modal-state35, #modal-state36,
     #modal-state37, #modal-state38, #modal-state39,
     #modal-state40, #modal-state41,
     
     #modal-stateTaco2,
     
     #modal-stateDine2,
    
     #modal-stateBreakfast2*/
     [id^="modal-state"]
     {
      display: none;
    }
    /*
     #modal-state1:checked + .modal-overlay1, #modal-state2:checked + .modal-overlay2, #modal-state3:checked + .modal-overlay3,
     #modal-state4:checked + .modal-overlay4, #modal-state5:checked + .modal-overlay5, #modal-state6:checked + .modal-overlay6,
     #modal-state7:checked + .modal-overlay7, #modal-state8:checked + .modal-overlay8, #modal-state9:checked + .modal-overlay9,
     #modal-state10:checked + .modal-overlay10, #modal-state11:checked + .modal-overlay11, #modal-state12:checked + .modal-overlay12,
     #modal-state13:checked + .modal-overlay13, #modal-state14:checked + .modal-overlay14, #modal-state15:checked + .modal-overlay15,
     #modal-state16:checked + .modal-overlay16, #modal-state17:checked + .modal-overlay17, #modal-state18:checked + .modal-overlay18,
     #modal-state19:checked + .modal-overlay19, #modal-state20:checked + .modal-overlay20, #modal-state21:checked + .modal-overlay21,
     #modal-state22:checked + .modal-overlay22, #modal-state23:checked + .modal-overlay23, #modal-state24:checked + .modal-overlay24,
     #modal-state25:checked + .modal-overlay25, #modal-state26:checked + .modal-overlay26, #modal-state27:checked + .modal-overlay27,
     #modal-state28:checked + .modal-overlay28, #modal-state29:checked + .modal-overlay29, #modal-state30:checked + .modal-overlay30,
     #modal-state31:checked + .modal-overlay31, #modal-state32:checked + .modal-overlay32, #modal-state33:checked + .modal-overlay33,
     #modal-state34:checked + .modal-overlay34, #modal-state35:checked + .modal-overlay35, #modal-state36:checked + .modal-overlay36,
     #modal-state37:checked + .modal-overlay37, #modal-state38:checked + .modal-overlay38, #modal-state39:checked + .modal-overlay39,
     #modal-state40:checked + .modal-overlay40, #modal-state41:checked + .modal-overlay41,
    
     
     #modal-stateTaco2:checked + .modal-overlayTaco2,
     
     #modal-stateDine2:checked + .modal-overlayDine2,
     
     #modal-stateBreakfast2:checked + .modal-overlayBreakfast2
     */
     
     [id^="modal-state"]:checked + [class^="modal-overlay"]
     {
      opacity: 1;
      animation: fade-in .4s;
      display: block;
    }
    /*
     .modaltime1, .modaltime2, .modaltime3, .modaltime4,
     .modaltime5, .modaltime6, .modaltime7, .modaltime8,
     .modaltime9, .modaltime10, .modaltime11, .modaltime12,
     .modaltime13, .modaltime14, .modaltime15, .modaltime16,
     .modaltime17, .modaltime18, .modaltime19, .modaltime20,
     .modaltime21, .modaltime22, .modaltime23, .modaltime24,
     .modaltime25, .modaltime26, .modaltime27, .modaltime28,
     .modaltime29, .modaltime30, .modaltime31, .modaltime32,
     .modaltime33, .modaltime34, .modaltime35, .modaltime36,
     .modaltime37, .modaltime38, .modaltime39, .modaltime40,
     .modaltime41*/
    
     [class^= "modaltime"] 
     {
      position:fixed;
      margin: 0 auto;
      padding: 30px 25px;
      background: #fff;
      right: 0;
      left: 0;
      text-align: center;
      box-shadow: 0px 12px 24px rgba(0, 0, 0, 0.2);
      max-width: 400px;
      line-height: 1.8;
      border:red solid 1px;
    }
    /*
     .modaltime1 h2, .modaltime2 h2, .modaltime3 h2, .modaltime4 h2,
     .modaltime5 h2, .modaltime6 h2, .modaltime7 h2, .modaltime8 h2,
     .modaltime9 h2, .modaltime10 h2, .modaltime11 h2, .modaltime12 h2,
     .modaltime13 h2, .modaltime14 h2, .modaltime15 h2, .modaltime16 h2,
     .modaltime17 h2, .modaltime18 h2, .modaltime19 h2, .modaltime20 h2,
     .modaltime21 h2, .modaltime22 h2, .modaltime23 h2, .modaltime24 h2,
     .modaltime25 h2, .modaltime26 h2, .modaltime27 h2, .modaltime28 h2,
     .modaltime29 h2, .modaltime30 h2, .modaltime31 h2, .modaltime32 h2,
     .modaltime33 h2, .modaltime34 h2, .modaltime35 h2, .modaltime36 h2,
     .modaltime37 h2, .modaltime38 h2, .modaltime39 h2, .modaltime40 h2,
     .modaltime41 h2 */
    
     [class^= "modaltime"] h2 
     {
      margin-top: 0;
      line-height: 25px;
      font-size: 22px;
      border-bottom: 1px solid #dce0d8;
      margin-bottom: 10px;
      padding-bottom: 10px;
      font-weight: 400;
    }
    
    @media all and (max-width: 470px) {
      .modaltime1, .modaltime6, .modaltime31, .modaltime32, .modaltime33 {
        width: 75%;
      }
      
      .modaltime1 h2, .modaltime6 h2, .modaltime31 h2,.modaltime32 h2,.modaltime33 h2{
        font-size: 20px;
      }
    
    }
    
    /*
     #modal-state1:checked + .modal-overlay1 .modaltime1, #modal-state2:checked + .modal-overlay2 .modaltime2, #modal-state3:checked + .modal-overlay3 .modaltime3,
     #modal-state4:checked + .modal-overlay4 .modaltime4, #modal-state5:checked + .modal-overlay5 .modaltime5, #modal-state6:checked + .modal-overlay6 .modaltime6,
     #modal-state7:checked + .modal-overlay7 .modaltime7, #modal-state8:checked + .modal-overlay8 .modaltime7, #modal-state9:checked + .modal-overlay9 .modaltime9,
     #modal-state10:checked + .modal-overlay10 .modaltime10, #modal-state11:checked + .modal-overlay11 .modaltime11, #modal-state12:checked + .modal-overlay12 .modaltime12,
     #modal-state13:checked + .modal-overlay13 .modaltime13, #modal-state14:checked + .modal-overlay14 .modaltime14, #modal-state15:checked + .modal-overlay15 .modaltime15,
     #modal-state16:checked + .modal-overlay16 .modaltime16, #modal-state17:checked + .modal-overlay17 .modaltime17, #modal-state18:checked + .modal-overlay18 .modaltime18,
     #modal-state19:checked + .modal-overlay19 .modaltime19, #modal-state20:checked + .modal-overlay20 .modaltime20, #modal-state21:checked + .modal-overlay21 .modaltime21,
     #modal-state22:checked + .modal-overlay22 .modaltime22, #modal-state23:checked + .modal-overlay23 .modaltime23, #modal-state24:checked + .modal-overlay24 .modaltime24,
     #modal-state25:checked + .modal-overlay25 .modaltime25, #modal-state26:checked + .modal-overlay26 .modaltime29, #modal-state27:checked + .modal-overlay27 .modaltime27,
     #modal-state28:checked + .modal-overlay28 .modaltime28, #modal-state29:checked + .modal-overlay29 .modaltime29, #modal-state30:checked + .modal-overlay30 .modaltime30,
     #modal-state31:checked + .modal-overlay31 .modaltime31, #modal-state32:checked + .modal-overlay32 .modaltime32, #modal-state33:checked + .modal-overlay33 .modaltime33,
     #modal-state34:checked + .modal-overlay34 .modaltime34, #modal-state35:checked + .modal-overlay35 .modaltime35, #modal-state36:checked + .modal-overlay36 .modaltime36,
     #modal-state37:checked + .modal-overlay37 .modaltime37, #modal-state38:checked + .modal-overlay38 .modaltime38, #modal-state39:checked + .modal-overlay39 .modaltime39,
     #modal-state40:checked + .modal-overlay40 .modaltime40, #modal-state41:checked + .modal-overlay41 .modaltime41,
     
     #modal-stateTaco2:checked + .modal-overlayTaco2 .modaltime2,
     #modal-stateDine2:checked + .modal-overlayDine2 .modaltime2,
     #modal-stateBreakfast2:checked + .modal-overlayBreakfast2 .modaltime2
    */
    [id^= "modal-state"]:checked + [class^= "modal-overlay"] [class^= "modaltime"]
    {
      top: 20%;
    }
    
    /*
     .modal-overlay-close1, .modal-overlay-close2, .modal-overlay-close3, .modal-overlay-close4,
     .modal-overlay-close5, .modal-overlay-close6, .modal-overlay-close7, .modal-overlay-close8,
     .modal-overlay-close9, .modal-overlay-close10, .modal-overlay-close11, .modal-overlay-close12,
     .modal-overlay-close13, .modal-overlay-close14, .modal-overlay-close15, .modal-overlay-close16,
     .modal-overlay-close17, .modal-overlay-close18, .modal-overlay-close19, .modal-overlay-close20,
     .modal-overlay-close21, .modal-overlay-close22, .modal-overlay-close23, .modal-overlay-close24,
     .modal-overlay-close25, .modal-overlay-close26, .modal-overlay-close27, .modal-overlay-close28,
     .modal-overlay-close29, .modal-overlay-close30, .modal-overlay-close31, .modal-overlay-close32,
     .modal-overlay-close33, .modal-overlay-close34, .modal-overlay-close35, .modal-overlay-close36,
     .modal-overlay-close37, .modal-overlay-close38, .modal-overlay-close39, .modal-overlay-close40,
     .modal-overlay-close41,
     
     .modal-overlay-closeTaco2,
     .modal-overlay-closeDine2,
     .modal-overlay-closeBreakfast2*/
    
     [class^="modal-overlay-close"] 
     {
      height: 100%;
      width: 100%;
      position: fixed;
      left: 0;
      top: 0;
      display:block;
    }
    /*
     .button-close1, .button-close2, .button-close3, .button-close4,
     .button-close5, .button-close6, .button-close7, .button-close8,
     .button-close9, .button-close10, .button-close11, .button-close12,
     .button-close13, .button-close14, .button-close15, .button-close16,
     .button-close17, .button-close18, .button-close19, .button-close20,
     .button-close21, .button-close22, .button-close23, .button-close24,
     .button-close25, .button-close26, .button-close27, .button-close28,
     .button-close29, .button-close30, .button-close31, .button-close32,
     .button-close33, .button-close34, .button-close35, .button-close36,
     .button-close37, .button-close38, .button-close39, .button-close40,
     .button-close41,
     
     .button-closeTaco2,
     .button-closeDine2,
     .button-closeBreakfast2*/
     [class^="button-close"]
     {
      text-decoration: none;
      position: absolute;
      color: #fff;
      background: #464646;
      padding: 0px 7px;
      font-weight: bold;
      top: 0px;
      right: 0;
      cursor: pointer
    }
    /*time end*/
    &#13;
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"></script>
    <div class="timebox"  >
    <div id="timeDiv2"></div>
    <label class="viewOpen2" for="modal-state2">View Hours&nbsp;&nbsp;<i class="fa fa-clock-o"></i></label>
    <input type="checkbox" name="modal-state2" id="modal-state2">
    <div class="modal-overlay2">
    <label for="modal-state2" class="modal-overlay-close2"></label>
    
    <div class="modaltime2">
    <label class="button-close2" for="modal-state2"><i class="fa fa-times"></i></label>
    <h2>We're Open At These Times</h2>
    <div id="Monday" class="dateTime">
    <div class="day">Monday</div>
    <div class="time">6am - 10pm</div>
    </div>
    <br>
    <div id="Tuesday" class="dateTime">
    <div class="day">Tuesday</div>
    <div class="time">6am - 10pm</div>
    </div>
    <br>
    <div id="Wednesday" class="dateTime">
    <div class="day">Wednesday</div>
    <div class="time">6am - 10pm</div>
    </div>
    <br>
    <div id="Thursday" class="dateTime">
    <div class="day">Thursday</div>
    <div class="time">6am - 10pm</div>
    </div>
    <br>
    <div id="Friday" class="dateTime">
    <div class="day">Friday</div>
    <div class="time">6am - 11pm</div>
    </div>
    <br>
    <div id="Saturday" class="dateTime">
    <div class="day">Saturday</div>
    <div class="time">6am - 11pm</div>
    </div>
    <br>
    <div id="Sunday" class="dateTime">
    <div class="day">Sunday</div>
    <div class="time">6am - 10pm</div>
    </div>
    
    </div>
    </div>
    </div>
    &#13;
    &#13;
    &#13;

1 个答案:

答案 0 :(得分:0)

假设您的星期五和星期六的开放时间是早上6点至晚上11:30,即06:00-23:30。条件是:

((dayOfWeek == 5 || dayOfWeek == 6) && hour >= 6 && (hour < 23 || minutes < 30)

如果你想在一小时之后移动收盘时间,那么它将是早上6点 - 上午12:30,这将是06:00 - 24:30,但由于一天结束于23:59,这意味着24:30实际上是0:第二天30点。因此,您必须将条件分为两部分:

((dayOfWeek == 5 || dayOfWeek == 6) && hour >= 6) //this checks Friday's and Saturday's opening time
    || ((dayOfWeek == 6 || dayOfWeek == 0) && hour == 0 && minutes < 30) //this checks the closing time on the next day (30 minutes after midnight of Saturday and Sunday)