您好目前我有一個JavaScript,顯示當前時間。是一個來自互聯網的例子。我該如何去做,以便當前顯示的時間比實際時間晚5分鐘。真的不知道時間是如何運作的。試圖改變一些數字,但無濟於事。當前時間(Javascript)在HTML
目前這是代碼。
$(document).ready(function()
{
var MONTHS = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ],
DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var date = new Date(new Date().getTime() - (5 * 60 * 1000));
$('#date').text(DAYS[date.getDay()] + " " + date.getDate() + ' ' + MONTHS[date.getMonth()] + ' ' + date.getFullYear());
function zeroPad(val) {
return ((val < 10) ? "0" : "") + val;
}
setInterval(function() {
var fiveMinutesAgo = new Date(new Date().getTime() - (5 * 60 * 1000));
$("#hours").text(zeroPad(fiveMinutesAgo.getHours()));
$("#min").text(zeroPad(fiveMinutesAgo.getMinutes()));
$("#sec").text(zeroPad(fiveMinutesAgo.getSeconds()));
}, 1000);
});
new Date()。getMinutes() - 5? – Dineshkumar