从MYSQL日期和时间倒计时

时间:2015-04-02 23:40:04

标签: php mysql

下面的代码只是说:时间到了!什么时候还在倒计时? 有人可以请解释/显示/告诉我如何解决这个问题。

目前我在表格(数据库)中只有一行,所以它应该显示而不是说时间。

由于

我重写了脚本,这是解决方案:

<?php 
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php date_default_timezone_set('GMT'); ?>
<?php
session_start();
// Run a select query to get my letest 6 items
// Connect to the MySQL database  
include "db-connect.php";

?>

<script type="text/javascript">
 function countDown(){  
     $(".show").each(function() {
          var elm = $(this);
          var difTime=this.timestamp;  
          var day=0,hours=0,minutes=0,seconds=0;  
          if(difTime>0){  
              day=Math.floor(difTime/84600);  
              hours=(Math.floor((difTime/3600))%24) + day*24 ;  
              minutes=Math.floor(difTime/60)%60;  
              seconds=Math.floor(difTime)%60;   
          }  
          else{  
              elm.removeClass("show"); //for remove class show
          }  
          elm.html(hours+' H '+minutes+' M '+seconds+' S ');  
      });
 }  
 function countDown_onLoad(){  
      $(".show").each(function() {
          this.timestamp = parseInt(this.firstChild.nodeValue,10);
      });
      setInterval(countDown,1000);
  }  
  $(document).ready(function() {  
      countDown_onLoad();  
  });  
</script>  

<?php

$show=mysql_query("SELECT * FROM `trackorders` WHERE `id` = 1");
while ($array = mysql_fetch_array($show))
{ 
   $timeStop = $array['end_date'];
   $deltaTimeServer = strtotime($timeStop)-time();
}


$init = $deltaTimeServer;
$hours = floor($init / 3600);
$minutes = floor(($init / 60) % 60);
$seconds = $init % 60;

echo "$hours:$minutes:$seconds";

?>

0 个答案:

没有答案
相关问题