我是建築和拍賣網站,每個產品都附有倒數計時器。拍賣網站的Javascript倒計時器
我有一個工作腳本從這裏(計算器) - >how to make countdown timer for bidding website
這是我的代碼
<script>
var before = ""
var current = "Ended"
var montharray = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
jQuery.fn.countdown = function(yr, m, d) {
$that = $(this);
theyear = yr;
themonth = m;
theday = d;
var today = new Date();
var todayy = today.getYear();
if (todayy < 1000)
todayy += 1900;
var todaym = today.getMonth();
var todayd = today.getDate();
var todayh = today.getHours();
var todaymin = today.getMinutes();
var todaysec = today.getSeconds();
var todaystring = montharray[todaym] + " " + todayd + ", " + todayy + " " + todayh + ":" + todaymin + ":" + todaysec
futurestring = montharray[m - 1] + " " + d + ", " + yr;
dd = Date.parse(futurestring) - Date.parse(todaystring);
dday = Math.floor(dd/(60 * 60 * 1000 * 24) * 1);
dhour = Math.floor((dd % (60 * 60 * 1000 * 24))/(60 * 60 * 1000) * 1);
dmin = Math.floor(((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000))/(60 * 1000) * 1);
dsec = Math.floor((((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000))/1000 * 1);
if (dday < 0 && dhour < 0 && dmin < 0 && dsec < 1) {
$that.val(current);
return;
}
else
$that.val(dday + "Days, " + dhour + ":" + dmin + ":" + dsec + before);
setTimeout(function() {
$that.countdown(theyear, themonth, theday);
}, 1000);
};
</script>
<input type="text" id="6" style="width: 900px">
<script>
$("#6").countdown(2011, 7, 27);
</script>
我的問題是我怎樣才能添加的時間呢?我不是那麼有經驗的JavaScript來操縱這與上班時間
只是通過更遙遠的日期..'$(「#6」)。倒計時(2012,7,27);''會將示例日期推出1年 – user20232359723568423357842364
@ user20232359723 568423357842364我的意思是我怎麼能通過一個日期時間作爲參數,並得到類似的倒計時 像..'$(「#6」)。倒計時(2012,7,27,12,10,15);' –