webForumDet fria alternativet

Ändra AM/PM klocka till 24h??

1 svar · 618 visningar · startad av wborg

wborgMedlem sedan dec. 2003209 inlägg
#1

Hej,

jag undrar om någon kan hjälpa mig att konvertera detta klock script till en 24 timmars klocka istället för en AM/PM klocka?

<SCRIPT language=JavaScript>
<!--

     var timerID = null
     var timerRunning = false

     function stopTimeKeep(){
         
         if(timerRunning)
             clearTimeout(timerID)
         timerRunning = false
     }

     function startTimeKeep(){
          
         stopTimeKeep()
         showtime()
     }

/*      var now = new Date()
      var hours = now.getHours()
      var minutes = now.getMinutes()
      var seconds = now.getSeconds()
*/

      var now = new Date();
<?php 
      print "var hours = ".date("H").";";
      print "var minutes = ".date("i").";";
      print "var seconds = ".date("s").";";
?>
      function showtime()
      {
           seconds =(seconds+1) % 60;
           if (seconds==0) 
           {
                minutes =(minutes+1) % 60;
                if (minutes==0) hours =(hours+1) % 24;
           }

         var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
         timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
         timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
         timeValue  += (hours >= 12) ? " P.M." : " A.M."
         document.jsclock.face.value = timeValue 
         timerID = setTimeout("showtime()",1000)
         timerRunning = true
     }
//-->
</SCRIPT>

/Stefan

dectgapMedlem sedan sep. 20021 655 inlägg
#2

Ändra

         var timeValue = "" + ((hours > 12) ? hours - 12 : hours)
         timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
         timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
         timeValue  += (hours >= 12) ? " P.M." : " A.M."

till

         var timeValue = hours;
         timeValue  += ((minutes < 10) ? ":0" : ":") + minutes
         timeValue  += ((seconds < 10) ? ":0" : ":") + seconds
132 ms totalt · 3 externa anrop · v20260731065814-full.ca5a5675
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
130 ms — hämta tråd, inlägg och bilagor (db)