时间自动跳

 2011年8月9日 9:34:44 星期二

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="YC.WebForm2" %>

<!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 runat="server">
    <title></title>

    <script language="javascript" type="text/javascript">
        function setTime() {
            var dt = new Date();
            var arr_week = new Array("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
            var strWeek = arr_week[dt.getDay()];
            var strHour = dt.getHours();
            var strMinutes = dt.getMinutes();
            var strSeconds = dt.getSeconds();
            if (strMinutes < 10) strMinutes = "0" + strMinutes;
            if (strSeconds < 10) strSeconds = "0" + strSeconds;
            var strYear = dt.getFullYear() + "年";
            var strMonth = (dt.getMonth() + 1) + "月";
            var strDay = dt.getDate() + "日";
            var strTime = strHour + ":" + strMinutes + ":" + strSeconds;
            document.getElementById("lbl_date").innerHTML = "现在是:" + strYear + strMonth + strDay + " " + strTime + "  " + strWeek;    /* time是上面DIV的ID值,看要把它放在网页哪边可以换了*/

        }
        setInterval("setTime()", 1000); /* 这个是跳动函数,后面是多久跳以毫秒,1000就是一秒跳动 */
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lbl_date" runat="server" />
    </div>
    </form>
</body>
</html>

 

2011年8月9 星期二 上午 9:36:20

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="bindData.connection.WebForm1" %>

<!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 runat="server">
    <title></title>

        <script language="Javascript">
            function tick() {
                var hours, minutes, seconds, xfile;
                var intHours, intMinutes, intSeconds;
                var today, theday;
                today = new Date();
                function initArray() {
                    this.length = initArray.arguments.length
                    for (var i = 0; i < this.length; i++)
                        this[i + 1] = initArray.arguments[i]
                }
                var d = new initArray("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
                theday = today.getYear() + "年" + [today.getMonth() + 1] + "月" + today.getDate() + " " + d[today.getDay() + 1];
                intHours = today.getHours();
                intMinutes = today.getMinutes();
                intSeconds = today.getSeconds();
                if (intHours == 0) {
                    hours = "12:";
                    xfile = "午夜";
                } else if (intHours < 12) {
                    hours = intHours + ":";
                    xfile = "上午";
                } else if (intHours == 12) {
                    hours = "12:";
                    xfile = "正午";
                } else {
                    intHours = intHours - 12
                    hours = intHours + ":";
                    xfile = "下午";
                }
                if (intMinutes < 10) {
                    minutes = "0" + intMinutes + ":";
                } else {
                    minutes = intMinutes + ":";
                }
                if (intSeconds < 10) {
                    seconds = "0" + intSeconds + " ";
                } else {
                    seconds = intSeconds + " ";
                }
                timeString = theday + " " + xfile + " " + hours + minutes + seconds;
                document.getElementById("lbl_date").innerHTML = timeString;
                window.setTimeout("tick();", 100);
            }
            window.onload = tick;//页面加载时出现时间
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="lbl_date" runat="server" />
    </div>
    </form>
</body>
</html>


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

来杯水

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值