作者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