2006/07/06 | 如何在网页中显示目前浏览者电脑的日期与时间
类别(技术文章) | 评论(0) | 阅读(266) | 发表于 16:12
<script language="javascript">
var nowDate,theDate,theDay,theYear,theMonth,theHour,theMin,theSec,timeValue;
function ShowDateTime()
{
weeks=new Array("日","一","二","三","四","五","六");
nowDate=new Date;

theDate=nowDate.getDate();
theDay=weeks[nowDate.getDay()];
theYear=nowDate.getYear();
theMonth=nowDate.getMonth()+1;
theHour=nowDate.getHours();
theMin=nowDate.getMinutes();
if(theMin<10)
{
theMin="0"+theMin;
}
theSec=nowDate.getSeconds();
if(theSec<10)
{
theSec="0"+theSec;
}
timeValue=theYear+"年"+theMonth+"月"+theDate+"日"+"星期"+theDay+""+theHour+":"+theMin+":"+theSec;

         //在标题处显示浏览者机器的系统日期与时间
window.document.title = timeValue;
         //每1秒钟刷新一次系统日期与时间
setTimeout("ShowDateTime()",1000);
}
ShowDateTime();
</script>
0

评论Comments

日志分类
首页[30]
转载文章[21]
技术文章[6]
美工[3]
全部都是我![0]