当前时间-倒计时下载

效果:

代码:

<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>倒计时js代码</title>
<style>
*
{
margin: 0;
padding: 0;
list-style: none;
}
body
{
font-size: 18px;
text-align: center;
}
.time
{
height: 30px;
padding: 200px;
}
</style>
</head>
<body>
</div>
<!--当前时间-->
<div id="show">
</div>
</body> <script>//当前时间
window.onload = function() {
var show = document.getElementById("show");
setInterval(function() {
var time = new Date();
// 程序计时的月从0开始取值后+1
var m = time.getMonth() + 1;
var t = time.getFullYear() + "-" + m + "-" + time.getDate() + " " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
show.innerHTML = t;
}, 1000);
};
</script> </html>

动态显示当前时间,带日期

效果:

代码:

//动态显示当前的时间
function GetTime(obj) {
var myDate = new Date();
var Today = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
//获取当前年
var Years = myDate.getFullYear();
//获取当前月
var Months = myDate.getMonth() + 1;
//获取当前日
var Dates = myDate.getDate(); //获取当前天是当前周的第几天
var Days = Today[myDate.getDay()]; //获取当前的时
var Hours = myDate.getHours();
//获取当前的分
var Minutes = myDate.getMinutes();
//获取当前的秒
var Seconds = myDate.getSeconds(); Months = Months < 10 ? "0" + Months : Months;
Dates = Dates < 10 ? "0" + Dates : Dates; Hours = Hours < 10 ? "0" + Hours : Hours;
Minutes = Minutes < 10 ? "0" + Minutes : Minutes;
Seconds = Seconds < 10 ? "0" + Seconds : Seconds; return Years + "年" + Months + "月" + Dates + "日" + " " + Days + " " + Hours + ":" + Minutes + ":" + Seconds;
} function showTitleInfo() {
document.getElementById("dateInfo").innerHTML = GetTime();
setTimeout("showTitleInfo()", 1000);
}
showTitleInfo();

最新文章

  1. h5engine造轮子
  2. BugFree 测试管理系统
  3. spring boot/cloud 应用监控
  4. AC_Dream 1224 Robbers(贪心)
  5. C# 微信海报
  6. node-webkit 新建实例窗口间通信问题解决办法
  7. javaNIO是什么?由那几部分组成?各部分的作用。
  8. 【转】Java 枚举7常见种用法
  9. fputcsv 和 fgetcsv
  10. LINUX修改IP地址
  11. Android kernel LOGO的更换方法
  12. Eclipse实现图形化界面插件-vs4e
  13. python note 14 其他函数及递归应用
  14. linux下部署tomcat 上线jpress博客系统
  15. LodopJS文档式模版的加载和赋值
  16. Java--- Ambiguous mapping. Cannot map &quot;***Controller&quot; been method解决办法
  17. 【洛谷P1248】加工生产调度
  18. json和jsonp的使用区别
  19. jquery的validate表单验证
  20. Shell 命令行快捷键

热门文章

  1. eclipse常用插件介绍
  2. LR URL编码和解码方法
  3. 《HTTP权威指南》学习笔记——HTTP报文
  4. Python+Django(Python Web项目初体验)
  5. easyui datagrid 单元格编辑(cell editing)
  6. GDAL------安装GDAL
  7. SPREAD for Windows Forms 代码片段
  8. Mac 使用 launchctl 定时运行程序(转载)
  9. 【RF库XML测试】Get Element
  10. Unity绘制Png图片