2014-01-26 108 views
1

我在尋找一個JavaScript這就是基於時間的倒計時HH/MM/SS和天倒計時基於出貨時間

現在訂購,我們在船舶訂單:22小時42敏3秒

週一至週五下午6點應(18:00 GMT +1) 週六和週日的訂單前放置的順序應該下午3點前放置(15:00 GMT +1)

回答

2

這可以做你在問什麼。見fiddle

$(document).ready(function() { 
    setInterval(function() { 
     var now = new Date(); 
     var day = now.getDay(); 
     var end; 

     if(day >= 1 && day <= 5) { 
      end = new Date(now.getYear(), now.getMonth(), day, 18, 0, 0, 0);  
     } else { 
      end = new Date(now.getYear(), now.getMonth(), day, 15, 0, 0, 0); 
     } 

     var timeleft = end.getTime() - now.getTime(); 
     var diff = new Date(timeleft); 


     $("#timeleft").html("Order now and we ship your order in: " + diff.getHours() + "h " + diff.getMinutes() + "Min " + diff.getSeconds() + "Sec"); 

    }, 1000); 
}); 
+0

比你這麼多! – mrdan