私は奇妙な問題を抱えています..私は秒カウンターで時間を表示する機能を持っていますが、秒のカウントが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);