作者ckroy (Hug)
看板Web_Design
标题[问题]显示时间的程式码问题
时间Wed Dec 13 16:35:46 2006
我用网页特效精灵的,但预设是12时制,请问要如何改成24时制,感谢!
<html>
<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">
<p><input name="thetime" style="font-size: 9pt;color:#000000;border:0"
size="12"></p>
</form>
</body>
</html>
--
One More Time, Baby I don't wanna let you go
One More Chance, It's only you, will always be with me
I could never say goodbye to the days we spent, Oh baby stay with me
One more time, time, time we spent
One more chance, chance, chance with me
One more kiss, kiss, kiss I want
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 203.67.78.174
1F:→ grence:timeValue += ((hours >12) ? hours -12 :hours) 12/13 17:17
2F:→ grence:这行在转换.. 12/13 17:18