clocktime_coupon_free.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. function lxfEndtime(){
  2. $(".clock_div").each(function(){
  3. var lxfday=$(this).attr("endtime");
  4. var endtime = new Date(lxfday).getTime();
  5. var nowtime = new Date().getTime();
  6. var youtime = endtime-nowtime;
  7. var seconds = youtime/1000;
  8. var mc = youtime/100;
  9. mc = Math.floor(mc % 10);
  10. var minutes = Math.floor(seconds/60);
  11. var hours = Math.floor(minutes/60);
  12. var days = Math.floor(hours/24);
  13. var CDay= days ;
  14. var CHour= hours % 24;
  15. var CMinute= minutes % 60;
  16. var CSecond= Math.floor(seconds%60);
  17. if(endtime<=nowtime){
  18. $(this).html("已过期")
  19. }else{
  20. var s_time = "";
  21. if(days > 0){
  22. s_time+= "<div class='time-block'>"+days+"</div> ";
  23. }
  24. if(CHour >0){
  25. s_time+="<div class='time-block'>"+CHour+"</div><div class='separator-block'>:</div>";
  26. }
  27. if(CMinute > 0){
  28. s_time+="<div class='time-block'>"+CMinute+"</div><div class='separator-block'>:</div>";
  29. }
  30. s_time+="<div class='time-block'>"+CSecond+"</div>";
  31. s_time+="<div class='time-desc'>后结束"+"</div>";
  32. $(this).html(s_time);
  33. }
  34. });
  35. setTimeout("lxfEndtime()",100);
  36. }