客户端js获得毫秒

<!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>客户端js获得毫秒</title>

<script>

/*客户端js获得毫秒 - start*/

var d, s = "";

var c = ":";

d = new Date();

s += ((d.getYear()<1900) ? (1900+d.getYear()) : d.getYear())+ "/";

s += (d.getMonth() + 1) + "/";

s += d.getDate() + "  ";

s += d.getHours() + c;

s += d.getMinutes() + c;

s += d.getSeconds() + c;

s += d.getMilliseconds();

alert(s); 

document.write(s);

/*客户端js获得毫秒 - end*/

</script>

 

<script type="text/javascript">

/*页面动态获得时间 - start*/

function todaydatetime() {

var Time = new Date();

var year = Time.getYear();

var month = Time.getMonth() + 1;

var day = Time.getDate();

var hour = Time.getHours();

var minute = Time.getMinutes();

var second = Time.getSeconds();

return timedate= year + "\年" + month + "\月" + day + "\日" + "  " + hour + ":" + minute + ":" + second;

}

</script> 

<script type="text/javascript">

function ShowDatetime()

{

var times = todaydatetime();

var divid = document.getElementById("nowtime");

divid.innerHTML = times;

setTimeout('ShowDatetime();',1000);

}

</script>

</head>

<body onload="ShowDatetime();">

<div id="nowtime"></div>

<!--页面动态获得时间 - end-->

</body>

</html>


阅读更多
文章标签: xhtml date html div c
个人分类: Javascript
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭