html代码如下:
复制代码 代码如下:
<div id="showTime"></div>
javascript 代码如下:时间显示格式为:2011-04-04 星期二 12:09:34
复制代码 代码如下:
function startTime() {
try{
var today = new Date();
var year = today.getFullYear();
var month = checkNum(today.getMonth()+1);
var date = checkNum(today.getDate());
var day = today.getDay();
var hour = checkNum(today.getHours());
var minute = checkNum(today.getMinutes());
var second = checkNum(today.getSeconds());
switch(day) {
case 1:
day = "一";
break;
case 2:
day = "二";
break;
case 3:
day = "三";
break;
case 4:
day = "四";
break;
case 5:
day = "五";
break;
case 6:
day = "六";
break;
case 7:
day = "日";
break;
}
var fullTime = year+"-"+month+"-"+date+" "+"星期"+day+" "+hour+":"+minute+":"+second;
document.getElementById("showTime").innerHTML = fullTime;
setInterval('startTime()', 1000);
}catch(e) {
alert(e.description);
}
}
function checkNum(num) {
if(num<10) {
num = "0"+num;
}
return num;
}
复制代码 代码如下:
<div id="showTime"></div>
javascript 代码如下:时间显示格式为:2011-04-04 星期二 12:09:34
复制代码 代码如下:
function startTime() {
try{
var today = new Date();
var year = today.getFullYear();
var month = checkNum(today.getMonth()+1);
var date = checkNum(today.getDate());
var day = today.getDay();
var hour = checkNum(today.getHours());
var minute = checkNum(today.getMinutes());
var second = checkNum(today.getSeconds());
switch(day) {
case 1:
day = "一";
break;
case 2:
day = "二";
break;
case 3:
day = "三";
break;
case 4:
day = "四";
break;
case 5:
day = "五";
break;
case 6:
day = "六";
break;
case 7:
day = "日";
break;
}
var fullTime = year+"-"+month+"-"+date+" "+"星期"+day+" "+hour+":"+minute+":"+second;
document.getElementById("showTime").innerHTML = fullTime;
setInterval('startTime()', 1000);
}catch(e) {
alert(e.description);
}
}
function checkNum(num) {
if(num<10) {
num = "0"+num;
}
return num;
}
标签:
显示,当时时间
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“javascript学习笔记(三)显示当时时间的代码”评论...
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。