您的位置:首页 > 编程语言 > ASP

asp.net网页中添加年月日时分秒星期。

2013-07-15 16:25 399 查看
html代码如下:

现在是<span id="TimeSpan"></span>

<script type="text/javascript">
ShowTime();
</script>

Js脚本

<script type="text/javascript">
function ShowTime() {
now = new Date();
hour = now.getHours();
minute = now.getMinutes();
second = now.getSeconds();
var day = ["日", "一", "二", "三", "四", "五", "六", ];
time_str = (hour < 10) ? ("0" + hour) : hour;
time_str += ":";
time_str += (minute < 10) ? ("0" + minute) : minute;
time_str += ":";
time_str += (second < 10) ? ("0" + second) : second;
$$("TimeSpan").innerHTML = "" + (now.getFullYear()) + "年" + (now.getMonth() + 1) + "月" + (now.getDate() + 0) + "日 " + time_str + " 星期" + day[new Date().getDay()];
setTimeout('ShowTime()', 1000);
}

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: