在timer 事件里输入
this.lable.Text = Convert .ToString (DateTime.Now.ToLocalTime());
制作在该页面停留时间JavaScript示例:
<!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>无标题文档</title>
<script language ="javascript">
var second=0;
var minute=0;
var hour=0;
window.setInterval ("OnlineTimes( );",1000);//每隔1秒调用OnlineStayTimes
function OnlineTimes( )
{
second++;
if(second==60)
{
second=0;minute+=1;
}
if(minute==60)
{
minute=0;
hour+=1;
}
document.getElementById("timeDwell").innerHTML="停留时间"+hour+"小时"+minute+"分钟"+second+"秒";
}
</script>
</head>
<body>
<label id="timeDwell"></label>
</body>
</html>
倒计时:
<!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>无标题文档</title>
<script type="text/javascript">
var minute=20;
var second=0;
setInterval("OnlineTimes()",1000);
function OnlineTimes(){
if(second==0){
minute--;
second=59;
}else{
second--;
}
document.getElementById("timeDwell").innerHTML="倒计时:"+minute+"分"+second+"秒";
}
</script>
</head>
<body>
<label id="timeDwell"></label>
</body>
</html>