前言:实时显示当前时间(英文版),一周的第几天用英文显示
效果:

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<div id="box"></div>
<script src='jquery.min.js'></script>
<script>
function formatDate() {
now = new Date();
var year = now.getFullYear(),
month = now.getMonth() + 1,
date = now.getDate(),
day = now.getDay(),
hour = now.getHours(),
minute = now.getMinutes(),
second = now.getSeconds();
minute = checkTime(minute);
month = checkTime(month);
date = checkTime(date);
hour = checkTime(hour);
second = checkTime(second);
day = checkday(day)
return year + " / " + month + " / " + date + " "+ day +" " + hour + ":" + minute + ":" + second;
}
function checkTime(i) {
if(i < 10) {
i = "0" + i
}
return i
}
function checkday(daynum){
switch (daynum){
case 0:
daynum=' Monday '
break;
case 1:
daynum=' Tuesday '
break;
case 2:
daynum=' Wednesday '
break;
case 3:
daynum=' Thursday '
break;
case 4:
daynum=' Friday '
break;
case 5:
daynum=' Saturday '
break;
case 6:
daynum=' Sunday '
break;
default:
break;
}
return daynum
}
showtime();
function showtime(){
var gettime = formatDate();
$("#box").text(gettime);
}
setInterval(function(){
showtime();//封装的显示时间的方法
},1000);
</script>
</body>
</html>
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/40539.html