ARTICLES
phpcms 调取时间 倒计时
2015-07-26 16:06:160字号:
  1.  {pc:get sql="SELECT begintime FROM kj_meeting_data where id='$id'}
  2.    {loop $data $v}
  3.             <p id="times"></p>
  4.             <SCRIPT LANGUAGE="JavaScript">
  5. function _fresh()
  6. {
  7.  var endtime=new Date("<?php echo(''.date('Y/m/d,h:i:s',$v['begintime']).''); ?>");//格式 2014/12/26,08:50:00
  8.  var nowtime = new Date();
  9.  var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000);
  10.  __d=parseInt(leftsecond/3600/24);
  11.  __h=parseInt((leftsecond/3600)%24);
  12.  __m=parseInt((leftsecond/60)%60);
  13.  __s=parseInt(leftsecond%60);
  14.  document.getElementById("times").innerHTML="距离会议开启还有"+__d+"天 "+__h+"小时"+__m+""+__s+"";
  15.  if(leftsecond<=0){
  16.  document.getElementById("times").innerHTML="<a href='#'>进入会场</a>";
  17.  clearInterval(sh);
  18.  }
  19. }
  20. _fresh()
  21. var sh;
  22. sh=setInterval(_fresh,1000);
  23. </SCRIPT>
  24. {/loop}
  25.  {/pc}