📄 datetime.js
字号:
var timerID = null;
var timerRunning = false;
var week = new Array('星期日','星期一','星期二','星期三','星期四','星期五','星期六','星期日');
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function startclock () {
stopclock();
showtime();
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
var timeValue = now.getFullYear()+"年";
timeValue += (now.getMonth()+1)+"月";
timeValue += now.getDate()+"日 ";
timeValue += ((hours >= 12) ? "下午 " : "上午 " );
timeValue += ((hours >12) ? hours -12 :hours);
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
timeValue += " "+week[now.getDay()];
document.getElementById("currentTime").innerHTML=timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
window.onload=startclock;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -