time.js

来自「物业管理和办公自动化系统」· JavaScript 代码 · 共 86 行

JS
86
字号

<script language="javascript">

/************************************************************************************************
''''''''''''   Client 函数Tick()				: 这个函数目前没有使用,原因是只能取到客户端的时间,而无法取到服务器端的时间 '''''''
''''''''''''                                       : 写在这里只是怕以后哪里需要这个功能的时候遗忘
'************************************************************************************************
' 函数名 : tick
' 输 入 : (无)
' 输 出 : (无)
' 功能描述: 动态刷新显示本机时间时分秒,
'             : 用法:在页面中添加<SCRIPT language="javascript" src="time.js"></SCRIPT>和
'             : <span width=75 id=clock><script language="JavaScript">tick();</script></span>语句即可
' 调用模块: 
' 作 者 : 周秋舫
' 日 期 : 2002-05-13
' 版 本 : 
'************************************************************************************************/

var NSkey = (navigator.appName=="Netscape");

function tick()
{
	var today;
	var timeString="";
	var hours, minutes, seconds, wday;
	var intHours, intMinutes, intSeconds;
	var wdaysE = new Array("SUN","MON","TUE","WED","THU","FRI","SAT");
	var wdaysC = new Array("","","","","","","");
	today = new Date();
	intHours = today.getHours();
	intMinutes = today.getMinutes();
	intSeconds = today.getSeconds();
	
	intHours = "<%=Hour(Now)%>"

	if(NSkey)
	{
		wday = wdaysE[today.getDay()];
	}
	else
	{
		wday = wdaysC[today.getDay()];
	}

	if(intHours < 10)
	{
		hours = "0" + intHours;
	}
	else
	{
		hours = intHours;
	}
	
	if(intMinutes < 10)
	{
		minutes = ":0" + intMinutes;
	}
	else
	{
		minutes = ":" + intMinutes;
	}

	if(intSeconds < 10)
	{
		seconds = ":0" + intSeconds;
	}
	else
	{
		seconds = ":" + intSeconds;
	}
	timeString += hours + minutes + seconds + " " + wday
	
	if(NSkey)
	{
		document.clock.document.open();
		document.clock.document.write(timeString);
		document.clock.document.close();
	}
	else
	{
		clock.innerHTML=timeString;
	}
	document.refreshTimer = setTimeout("tick();",1000);
}
</script>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?