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>