douchu2823 2017-04-30 21:13
浏览 53

jQuery倒计时datetime不起作用

I'm writing countdown between datetime values with jQuery. But this code doesn't print anything to page. The datetime values $_endDateTime and $_startDateTime are coming from included page in 2017-04-30 23:55:32 format.

<!--
Creator: Ahmet ÇELİKEZER
Date: 30.04.2017
Variables Needed: $_endDateTime , $_startDateTime
-->
<?php
$dif_int = strtotime($_endDateTime) - strtotime($_startDateTime); //Diffrance between dates as interval
?>
<script>
$(function(){
var secLeft=<?php echo $dif_int; ?>;
var minLeft=0;
var hourLeft=0;
var dayLeft=0;
$.countBack=function()
{
  if(secLeft>1)
  {
    secLeft--;
    //Split Days,Hours,Minutes,Seconds
    /*
     1Day=86400 Sec
     1Hour=3600 Sec
     1Minute=60 Sec
     1Second=1 Sec
    */
    if(secLeft>86400)
    {
      dayLeft=secLeft / 86400;
      secLeft=secLeft % 86400;
    }
    if(secLeft>3600)
    {
      hourLeft=secLeft / 3600;
      secLeft=secLeft % 3600;
    }
    if(secLeft>60)
    {
      minLeft=secLeft / 60;
      secLeft=secLeft % 60;
    }
    $("#printTime").Text(dayLeft+" Gün "+hourLeft+" Saat "+minLeft+" Dakika "+secLeft+" Saniye");
  }
  else {
    {
      //Time Ended

    }
  }
}
setInterval("$.countBack()",1000);
})
</script>
<p id="printTime"></p>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何用stata画出文献中常见的安慰剂检验图
    • ¥15 c语言链表结构体数据插入
    • ¥40 使用MATLAB解答线性代数问题
    • ¥15 COCOS的问题COCOS的问题
    • ¥15 FPGA-SRIO初始化失败
    • ¥15 MapReduce实现倒排索引失败
    • ¥15 ZABBIX6.0L连接数据库报错,如何解决?(操作系统-centos)
    • ¥15 找一位技术过硬的游戏pj程序员
    • ¥15 matlab生成电测深三层曲线模型代码
    • ¥50 随机森林与房贷信用风险模型