关闭

客户端js获得毫秒

标签: xhtmldatehtmldivc
1366人阅读 评论(0) 收藏 举报
分类:

<!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>


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:735237次
    • 积分:10987
    • 等级:
    • 排名:第1501名
    • 原创:480篇
    • 转载:10篇
    • 译文:0篇
    • 评论:29条
    文章分类
    最新评论