JS获取当前时间,显示“上午”、“下午”的js 特效


J这个jS特效能获取当前时间,显示“上午”、“下午”

最后效果如:下午 4:44:20 这样的格式,并且时间的秒数是变化的

这个网页特效代码如下

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JS获取当前时间,显示“上午”、“下午”丨芯晴网页特效丨CsrCode.Cn</title>
</head>
<body onload="startclock()">
<script language=JavaScript>
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;}
function startclock () {
stopclock();
showtime();}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
timeValue += ((hours >12) ? hours -12 :hours)
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
document.clock.thetime.value = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;}
</SCRIPT>
<form name=clock >
<input name=thetime style="font-size: 9pt;color:#000000;border:0" size=12>
</form>
</body>
</html>


本文出处:http://www.ablanxue.com/shtml/201209/1311.shtml