Ankündigung

Einklappen
Keine Ankündigung bisher.

Problem mit der Uhrzeit

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Problem mit der Uhrzeit

    Hi, bin ein totaler n00b was java angeht Ware super, wenn mir jemand helfen könnte.

    Meine Uhr in meinem Portal funktioniert nicht richtig... Sie zeigt für "17:08:54" "17:8:54" an. Also lässt die 0 vor den Minuten weg. Bei den Sekunden taucht das Problem nicht auf.

    Habe eben schon rumprobiert, hat aber nichts geholfen. Hab den Code-Schnipsel mal eben kopiert. Vielleicht findet ja jemand auf Anhieb den Fehler?

    Lasst Euch an den "$LAN_XYZ nicht stören...

    Code:
    <script type="text/javascript"> 
    <!-- 
    
    var DayNam = new Array( 
    "<?php echo isset($LAN_407)?$LAN_407:"Sontag"; ?>", 
    "<?php echo isset($LAN_401)?$LAN_401:"Montag"; ?>", 
    "<?php echo isset($LAN_402)?$LAN_402:"Dienstag"; ?>", 
    "<?php echo isset($LAN_403)?$LAN_403:"Mittwoch"; ?>", 
    "<?php echo isset($LAN_404)?$LAN_404:"Donnerstag"; ?>", 
    "<?php echo isset($LAN_405)?$LAN_405:"Freitag"; ?>", 
    "<?php echo isset($LAN_406)?$LAN_406:"Samstag"; ?>"); 
    
    var MnthNam = new Array( 
    "<?php echo isset($LAN_411)?$LAN_411:"Januar"; ?>", 
    "<?php echo isset($LAN_412)?$LAN_412:"Februar"; ?>", 
    "<?php echo isset($LAN_413)?$LAN_413:"M&rz"; ?>", 
    "<?php echo isset($LAN_414)?$LAN_414:"April"; ?>", 
    "<?php echo isset($LAN_415)?$LAN_415:"Mai"; ?>", 
    "<?php echo isset($LAN_416)?$LAN_416:"Juni"; ?>", 
    "<?php echo isset($LAN_417)?$LAN_417:"Juli"; ?>", 
    "<?php echo isset($LAN_418)?$LAN_418:"August"; ?>", 
    "<?php echo isset($LAN_419)?$LAN_419:"September"; ?>", 
    "<?php echo isset($LAN_420)?$LAN_420:"Oktober"; ?>", 
    "<?php echo isset($LAN_421)?$LAN_421:"November"; ?>", 
    "<?php echo isset($LAN_422)?$LAN_422:"Dezember"; ?>"); 
    
    function tick() { 
      var hours, minutes, seconds, ap; 
      var intHours, intMinutes, intSeconds;  var today; 
      today = new Date(); 
      intDay = today.getDay(); 
      intDate = today.getDate(); 
      intMonth = today.getMonth(); 
      intYear = today.getYear(); 
      intHours = today.getHours(); 
      intMinutes = today.getMinutes(); 
      intSeconds = today.getSeconds(); 
      timeString = DayNam[intDay]+", "+intDate; 
      if (intDate == 1 || intDate == 21 || intDate == 31) { 
        timeString= timeString + "."; 
      } else if (intDate == 2 || intDate == 22) { 
        timeString= timeString + "."; 
      } else if (intDate == 3 || intDate == 23) { 
        timeString= timeString + "."; 
      } else { 
        timeString = timeString + "."; 
      } 
      if (intYear < 2000){ 
       intYear += 1900; 
      } 
      timeString = timeString+""+MnthNam[intMonth]+" "+intYear+', '+intHours+":"+intMinutes; 
      if (intHours == 0) { 
         hours = "12:"; 
         ap = ""; 
      } else if (intHours < 12) { 
         hours = intHours+":"; 
         ap = ""; 
      } else if (intHours == 12) { 
         hours = "12:"; 
         ap = ""; 
      } else { 
         intHours = intHours - 12 
         hours = intHours + ":"; 
         ap = ""; 
      } 
      if (intMinutes < 10) { 
         minutes = "0"+intMinutes; 
      } else { 
         minutes = intMinutes; 
      } 
      if (intSeconds < 10) { 
         seconds = ":0"+intSeconds; 
      } else { 
         seconds = ":"+intSeconds; 
      } 
      timeString = (document.all)? timeString+""+seconds+" "+ap:timeString+" "; 
      var clock = (document.all) ? document.all("Clock") : document.getElementById("Clock"); 
      clock.innerHTML = timeString; 
      (document.all)?window.setTimeout("tick();", 1000):window.setTimeout("tick();", 6000); 
    } 
    
    tick(); 
    
    //--> 
    </script>

  • #2
    Re: Problem mit der Uhrzeit

    Zitat von vilsa
    Hi, bin ein totaler n00b was java angeht
    man siehts...
    JAVA hat nichts mit JavaScript zu tun
    wegen deinem problem: er ignoriert die 0 bei den minuten anscheinend
    bei den sekunden ignoriert er sie nicht, da noch ein ":" davor ist

    Kommentar


    • #3
      Re: Problem mit der Uhrzeit

      Zitat von burner.nst
      man siehts...
      wie gesagt...

      tja, also habs jetzt geändert, muss jetzt aber 50 Minuten das Ergebnis abwarten...

      Kommentar


      • #4
        ging nicht

        Kommentar


        • #5
          probiers mal so!

          Code:
          function runClock()
          {
                  theTime = window.setTimeout("runClock()", 1000);
                  d = new Date();
                  hr = d.getHours();
                  min = d.getMinutes();
                  sec = d.getSeconds();
                  
                  if(min <= 9)
                  {
                          min="0"+min
                  }
          	
          	if(sec <= 9)
          	{
          		sec="0"+sec
          	}
          
                  document.form.clock.value=""+hr+":"+min+":"+sec+"";
          }
          runClock();

          Kommentar


          • #6
            nee, das wars auch nicht.

            habs jetzt aber herausgefunden. Danke für die Hilfe!

            Wer wissen möchte, so klappt es:

            Code:
            <script type="text/javascript">
            <!--
            
            var DayNam = new Array(
            "<?php echo isset($LAN_407)?$LAN_407:"Sontag"; ?>",
            "<?php echo isset($LAN_401)?$LAN_401:"Montag"; ?>",
            "<?php echo isset($LAN_402)?$LAN_402:"Dienstag"; ?>",
            "<?php echo isset($LAN_403)?$LAN_403:"Mittwoch"; ?>",
            "<?php echo isset($LAN_404)?$LAN_404:"Donnerstag"; ?>",
            "<?php echo isset($LAN_405)?$LAN_405:"Freitag"; ?>",
            "<?php echo isset($LAN_406)?$LAN_406:"Samstag"; ?>");
            
            var MnthNam = new Array(
            "<?php echo isset($LAN_411)?$LAN_411:"Januar"; ?>",
            "<?php echo isset($LAN_412)?$LAN_412:"Februar"; ?>",
            "<?php echo isset($LAN_413)?$LAN_413:"M&auml;rz"; ?>",
            "<?php echo isset($LAN_414)?$LAN_414:"April"; ?>",
            "<?php echo isset($LAN_415)?$LAN_415:"Mai"; ?>",
            "<?php echo isset($LAN_416)?$LAN_416:"Juni"; ?>",
            "<?php echo isset($LAN_417)?$LAN_417:"Juli"; ?>",
            "<?php echo isset($LAN_418)?$LAN_418:"August"; ?>",
            "<?php echo isset($LAN_419)?$LAN_419:"September"; ?>",
            "<?php echo isset($LAN_420)?$LAN_420:"Oktober"; ?>",
            "<?php echo isset($LAN_421)?$LAN_421:"November"; ?>",
            "<?php echo isset($LAN_422)?$LAN_422:"Dezember"; ?>");
            
            function tick() {
              var hours, minutes, seconds, ap;
              var intHours, intMinutes, intSeconds;  var today;
              today = new Date();
              intDay = today.getDay();
              intDate = today.getDate();
              intMonth = today.getMonth();
              intYear = today.getYear();
              intHours = today.getHours();
              intMinutes = today.getMinutes();
              intSeconds = today.getSeconds();
              timeString = DayNam[intDay]+", "+intDate;
              if (intDate == 1 || intDate == 21 || intDate == 31) {
                timeString= timeString + ".";
              } else if (intDate == 2 || intDate == 22) {
                timeString= timeString + ".";
              } else if (intDate == 3 || intDate == 23) {
                timeString= timeString + ".";
              } else {
                timeString = timeString + ".";
              } 
              if (intYear < 2000){
            	intYear += 1900;
              }
              timeString = timeString+""+MnthNam[intMonth]+" "+intYear+', '+intHours;
              if (intHours == 0) {
                 hours = "12:";
                 ap = "";
              } else if (intHours < 12) { 
                 hours = intHours+":";
                 ap = "";
              } else if (intHours == 12) {
                 hours = "12:";
                 ap = "";
              } else {
                 intHours = intHours - 12
                 hours = intHours + ":";
                 ap = "";
              }
              if (intMinutes < 10) {
                 minutes = ":0"+intMinutes;
              } else {
                 minutes = ":"+intMinutes;
              }
              if (intSeconds < 10) {
                 seconds = ":0"+intSeconds;
              } else {
                 seconds = ":"+intSeconds;
              }
              timeString = (document.all)? timeString+""+minutes+""+seconds+" "+ap:timeString+" ";
              var clock = (document.all) ? document.all("Clock") : document.getElementById("Clock");
              clock.innerHTML = timeString;
              (document.all)?window.setTimeout("tick();", 1000):window.setTimeout("tick();", 6000);
            }
            
            tick();
            
            //-->
            </script>

            Kommentar

            Lädt...
            X