我有奇怪的問題..我有一個功能,以顯示與秒計數的時間,但我發送特定的時間(小時和分鐘)作爲參數時,第二個到達59的計數沒有增加分鐘,我不知道如果與時間相同問題的時候分鐘就會59分鐘當前時間秒
function updateClock(current_hours,current_minutes) {
var currentTime = new Date ();
var currentHours = current_hours;
var currentMinutes = current_minutes;
var currentSeconds = currentTime.getSeconds ();
// Pad the minutes and seconds with leading zeros, if required
currentMinutes = (currentMinutes < 10 ? "0" : "") + currentMinutes;
currentSeconds = (currentSeconds < 10 ? "0" : "") + currentSeconds;
// Choose either "AM" or "PM" as appropriate
var timeOfDay = (currentHours < 12) ? "AM" : "PM";
// Convert the hours component to 12-hour format if needed
currentHours = (currentHours > 12) ? currentHours - 12 : currentHours;
// Convert an hours component of "0" to "12"
currentHours = (currentHours == 0) ? 12 : currentHours;
// Compose the string for display
var currentTimeString = currentHours + ":" + currentMinutes + ":" + currentSeconds + " " + timeOfDay;
// Big font time
$('.big_time').html("<span></span>" + currentTimeString);
// Time in red triangle in the track bar
$('.time').html(currentTimeString);
}
我呼籲在裏面的文件準備像其他文件這一功能..我這裏發出從API檢索的數據(小時和分鐘)
current_hours = data.current_hours;
current_minutes = data.current_minutes;
setInterval(function(){updateClock(current_hours,current_minutes)},1000);
你能請張貼你在哪裏調用'updateClock'的代碼? – C5H8NNaO4
如果你保持傳球同樣小時和分鐘,顯然它不會改變:) –
請我所做的編輯上更多的澄清可能的問題有一些失蹤,我沒有 –