-1
<? 
include("commonfile.php");
$start = date("Y-m-d H:i:s");
$end = $_POST['date']." ".$_POST['time'];
if(isset($_POST['productid']) && $_POST['productid']!=""){
    $productid = $_POST['productid'];
    $expdata = getdata("SELECT expire_date,expire_time from tbl_listing_master WHERE listingid=".$productid." AND currentstatus=0");    
    $time_rs = mysql_fetch_array($expdata);
    $expdate = $time_rs[0];
    $exptime = $time_rs[1];
    $end = $expdate." ".$exptime;
}
$n = array("expdate" => $end); 
echo json_encode($n);  
?>

これは、私が http://keith-wood.name/countdown.html Countdown for jQuery v1.6.0 を使用しているカウント ダウンのバージョンです。

4

1 に答える 1

1

問題は日付の解析です (このコードは、dup の質問のリンクから取得しました)。

function updateCountdown(el, date, time, productId) {
    $.ajax({
      type: "POST",
      url: "../coding/fetch_time_forquery.php",
      dataType: "json",
      data: {date: date, time: time, productid: productId },
      success: function(data)
      {
        newYear = new Date (data.expdate);
         $(el).countdown({until:newYear} );
      }

    });
}

ここで日付を解析する必要があります:newYear = new Date (data.expdate);ですが、php から返される形式は2012-08-31 2:33:35.. タイムスタンプだけを返した方が簡単です。

PHP でこれを行う$endには、文字列ではなくタイムスタンプに変換する必要があります。

$n = array("expdate" => strtotime($end) . '000' ); // add milliseconds

jsで:

newYear = new Date ( parseInt( data.expdate, 10 ) );

動作するはずです

于 2012-08-30T19:57:26.943 に答える