0
我試圖使用jQuery倒計時(http://code.google.com/p/jquery-countdown/)來顯示倒數到特定的日期和時間,但你需要編程jQuery調用的天數,小時數,分鐘數和秒數。PHP/JQuery/JavaScript倒計時
我不太清楚如何在JS中做到這一點,但我想通過PHP來計算時間,然後讓它插入這些變量將工作。我在網上找到了這個PHP函數,但我不確定添加$ seconds_left的算法。有人可以幫忙嗎?
function countdown($year, $month, $day, $hour, $minute)
{
// make a unix timestamp for the given date
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
// get current unix timestamp
$today = time();
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;
global $days_left;
global $hours_left;
global $minutes_left;
$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
}
謝謝!