当前时间 js
效果:

代码:
<!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();
当前时间 js的更多相关文章
- js获取当前时间&js 页面时钟
js获取当前时间 //获取当前时间,格式YYYY-MM-DD function getNowFormatDate() { var date = new Date(); var seperator1 = ...
- js获取当前时间,js时间函数
Js获取当前日期时间及其它操作,js时间函数 var myDate = new Date(); myDate.getYear(); //获取当前年份(2位) myDate.getFullYear(); ...
- 页面显示时间js
//页面显示时间 <span align="left" id="OperatorTime"> </span> <script> ...
- js格式化时间 js格式化时间戳
一个js格式化时间和js格式化时间戳的例子. 代码:/** * 时间对象的格式化; */Date.prototype.format = function(format) { /* * eg:forma ...
- 日期时间JS插件
首先要引入基本文件:bootstrap的基本js和css文件,因为用到了jquery所以要引入jquery文件 <script src="jquery-1.11.2.min.js&qu ...
- MVC中的时间js格式化
记录下我遇到的一个,MVC中post请求返回一个JSON字符串,其中包含数据库中的时间格式(如:/Date(10000000000)/),不知道怎么处理.百度的方法都不适用,经自己研究,做成了一个Jq ...
- js动态获取当前系统时间+js字符串转换为date日期对象
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...
- 时间js
function DateUtil(){ this.url = ""; this.op={ partten:{mdy:"m/d/y",ymd:"y/m ...
- 时间js转换方法Date("149...") 转成 2016-7-12 21:23:34 009
function timeFormatter(value) { var da = new Date(parseInt(value.replace("/Date(", &q ...
随机推荐
- poj1741 bzoj2152
树分治入门 poj1741是男人八题之一,经典的树分治的题目这里用到的是点分治核心思想是我们把某个点i作为根,把路径分为过点i和不过点i先统计过点i这样的路径数,然后在统计其子树中的答案,这样就不断地 ...
- BZOJ2464: 中山市选[2009]小明的游戏
2464: 中山市选[2009]小明的游戏 Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 280 Solved: 124[Submit][Statu ...
- Windows Server基础架构云参考架构:硬件之上的设计
作者 王枫 发布于2014年1月27日 综述 毫无疑问,移动互联网.社交网络.大数据和云计算已经成为IT发展的四个大的趋势.其中云计算又为前三个提供了一个理想的平台.今天不仅互联网公司,很多传统行业的 ...
- Can't initialize OCI. Error -1
今天使用Toad连接Oracle时出现"Can't initialize OCI. Error -1" 解决方法 因为是刚做的windows 7系统,所以没有设置更改通知的时间 把 ...
- Parallels Desktop 7用bootcamp安装win7 后如何激活WIN7
在parallels的选项中,在硬件选项卡的引导标记中添加:kernel.waet.enable=0 ,重新启动win7即可激活.
- 今天遇到的i++问题之记录
今天逛贴吧看到的,与自己预想的不同,于是在群里求解后方得知答案,遂记录之.代码来袭. function a(){ var i=1; i++; alert(i); } var c = a(); c(); ...
- 洛谷1377 M国王 (SCOI2005互不侵犯King)
洛谷1377 M国王 (SCOI2005互不侵犯King) 本题地址:http://www.luogu.org/problem/show?pid=1377 题目描述 天天都是n皇后,多么无聊啊.我们来 ...
- 每隔一段时间执行一次函数。window.setTimeout
timer2 = window.setTimeout("showTaxi()", 30000);//30秒从后台获取一次数据,显示在地图上. 原来试过 setInterval . ...
- xls 和 xml 数据 排序 绑定 -原创
xls 和 xml 排序 xml: <?xml version="1.0" encoding="UTF-8"?> <?xml-styleshe ...
- hdoj 1509 Windows Message Queue【优先队列】
Windows Message Queue Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...