clocktime.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 = "<span class='clock-icon'></span><span class='slogan'>剩余</span>";
  21. if(days > 0){
  22. s_time+= "<span class='number'>"+days+"</span><span>天</span>";
  23. }
  24. if(CHour >0){
  25. s_time+="<span class='number'>"+CHour+"</span><span>:</span>";
  26. }
  27. if(CMinute > 0){
  28. s_time+="<span class='number'>"+CMinute+"</span><span>:</span>";
  29. }
  30. s_time+="<span class='number'>"+CSecond+"</span><span></span>";
  31. s_time+="<span class='number'>."+mc+"</span><span></span>";
  32. $(this).html(s_time);
  33. }
  34. });
  35. setTimeout("lxfEndtime()",100);
  36. }