function showTime() {
var show = document.createElement('div');
show.setAttribute('id','d1');
document.body.appendChild(show);
var d1 = document.getElementById('d1');
var currentTime = new Date;
var hours = currentTime.getHours();
if(hours < 10) {
hours = '0' + hours;
}
var minutes = currentTime.getMinutes();
if(minutes < 10) {
minutes = '0' + minutes;
}
var seconds = currentTime.getSeconds();
if(seconds < 10) {
seconds = '0' + seconds;
}
d1.innerHTML = currentTime.getFullYear() + '年' + (currentTime.getMonth() + 1)
+ '月' + currentTime.getDate() + '日' + ' ' + hours + '时' + minutes + '分' + seconds;
}
window.onload = function() {
setInterval('showTime()',1000);
}