我的英语很差,所以我会犯错误。
两天前我写了时钟区,但效果很差。往下看 你可以在那里看到我的代码。我需要你的建议。
<script>
function Clock(time_zone) {
var time = new Date();
var hours = time.getUTCHours() + time_zone;
var minutes = time.getUTCMinutes();
var seconds = time.getUTCSeconds();
var suffix = "AM";
var day = time.getDate();
var month = time.getMonth();
var year = time.getFullYear();
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
if (hours < 0) {
hours += 24;
}
if (hours > 11) {
suffix = "PM";
hours -= 12;
}
if (hours == 0) {
hours = 12;
}
if (hours < 10) {
hours = "0" + hours;
}
if (minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
var time_span = document.getElementById('time');
var suffix_span = document.getElementById('suffix');
var date_span = document.getElementById('date');
time_span.innerHTML = hours + ":" + minutes + ":" + seconds;
suffix_span.innerHTML = suffix;
date_span.innerHTML = day + " " + months[month] + " " + year;
setTimeout(function(){Clock(time_zone)}, 1000);
}
window.onload = function()
{
Clock(2);
}
</script>
这是更改区域的按钮。
<input type="button" onClick="Clock(5)" value="AMSTERDAM" name="AMSTERDAM"/>
当我单击此按钮时,我的时间在旧区域时间(时钟(2))和新区域时间(时钟(5))之间闪烁
能告诉我怎么修吗???
感谢您的所有建议。
拜托,你会改善我的语言错误。