Date对象的常用方法写一个当前时间的绑定
2013-04-16 19:52
483 查看
</head>
<style type="text/css">
.col{ color:#FFF; background-color:#39F; font-size:18px}
</style>
<script language="javascript">
function time()
{
var nowtime=new Date();
var year=nowtime.getYear();//返回年份
var month=nowtime.getMonth()+1;//返回月份值
var day=nowtime.getDate();//返回日期1-31
var hour=nowtime.getHours();//返回小时数
var minute=nowtime.getMinutes()//返回分钟数
var second=nowtime.getSeconds();//返回秒数
var haomiao=nowtime.getMilliseconds();//返回毫秒秒数
var time1=year+"/"+month+"/“+day+" "+hour+":"+minute+":"+second+" "+haomiao;//将时间拼接起来
document.getElementById("nowtime1").innerHTML=time1;
setTimeout("time()",1);
}
</script>
<body>
<input type="button" value="显示当前时间" onclick="time()">
<label id="nowtime1" class="col"></label>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style type="text/css">
.col{ color:#F00; font-size:36px}
</style>
<script language="javascript">
function test()
{
var time=new Date();
var year=time.getYear();
var da=time.getDate();
var day=time.getMonth();
var hor=time.getHours();
var mi=time.getMinutes();
var sc=time.getSeconds();
var hm=time.getMilliseconds();
var pj=year+"-"+eval(day+1)+"-"+da+"-"+" "+hor+":"+mi+":"+sc+":"+hm;
document.getElementById("tt").innerHTML=pj;
setTimeout("test()",1);
}
</script>
<body>
<input type="button" value="显示" onclick="test()">
<label id="tt" class="col"></label>
</body>
</html>
<style type="text/css">
.col{ color:#FFF; background-color:#39F; font-size:18px}
</style>
<script language="javascript">
function time()
{
var nowtime=new Date();
var year=nowtime.getYear();//返回年份
var month=nowtime.getMonth()+1;//返回月份值
var day=nowtime.getDate();//返回日期1-31
var hour=nowtime.getHours();//返回小时数
var minute=nowtime.getMinutes()//返回分钟数
var second=nowtime.getSeconds();//返回秒数
var haomiao=nowtime.getMilliseconds();//返回毫秒秒数
var time1=year+"/"+month+"/“+day+" "+hour+":"+minute+":"+second+" "+haomiao;//将时间拼接起来
document.getElementById("nowtime1").innerHTML=time1;
setTimeout("time()",1);
}
</script>
<body>
<input type="button" value="显示当前时间" onclick="time()">
<label id="nowtime1" class="col"></label>
</body>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<style type="text/css">
.col{ color:#F00; font-size:36px}
</style>
<script language="javascript">
function test()
{
var time=new Date();
var year=time.getYear();
var da=time.getDate();
var day=time.getMonth();
var hor=time.getHours();
var mi=time.getMinutes();
var sc=time.getSeconds();
var hm=time.getMilliseconds();
var pj=year+"-"+eval(day+1)+"-"+da+"-"+" "+hor+":"+mi+":"+sc+":"+hm;
document.getElementById("tt").innerHTML=pj;
setTimeout("test()",1);
}
</script>
<body>
<input type="button" value="显示" onclick="test()">
<label id="tt" class="col"></label>
</body>
</html>
相关文章推荐
- python学习之获取当前时间的方法(可以任意取时间的任何一个对象显示)
- Date对象中处理时间和日期的常用方法
- Date对象中处理时间和日期的常用方法
- js 小技巧 (速将一个字符串或者时间戳转化成Date对象)
- Java之日期时间常用的公共方法UtilForDate
- SQL 常用的获取Date时间相关处理方法
- Java设置session超时(失效)的时间 在一般系统登录后,都会设置一个当前session失效的时间,以确保在用户长时间不与服务器交互,自动退出登录,销毁session 具体设置的方法有三种:
- C#中PropertyGrid控件绑定对象后更改属性值写回到xml中的一个有效方法
- JavaScript中Date对象的常用方法示例
- 给 Javascript 的 日期(Date)对象扩展一个格式化(format)方法
- 一个包含完整的特性(date(日期),body(正文))和方法的Blog对象!!!
- 创建一个Date.text文件,获取当前的日期,将日期格式为“2013/02/14 05:20:00”的形式。然后一秒钟记录一次,将新的时间存入到文件中。
- 一个Flex 常用的时间方法类
- String\StringBuffer\StringBuilder的不同 基本常用类 Date时间类 Math数学类的基本方法
- selenium之 一个不常用但又很有用的方法(switch_to.active_element),获取当前焦点元素
- JS之Date对象和获取系统当前时间(转)
- php5中date()得出的时间为什么不是当前时间的解决方法
- JS- 获取当前时间、Date对象在移动端中异常处理
- JavaScript基础 使用new Date() 创建当前日期时间对象
- selenium之 一个不常用但又很有用的方法(switch_to.active_element),获取当前焦点元素