# Uhrzeitproblem



## java_newbie (8. Jul 2004)

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... 


```
<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>
```


----------



## Beni (8. Jul 2004)

JavaScript ist nicht Java!

verschoben.


----------



## Guest (8. Jul 2004)

oh, sorry...    vielleicht weiß ja jemand trotzdem eine Antwort?!


----------



## KSG9|sebastian (8. Jul 2004)

ich nehm mal an, dass du bei der Ausgabe der Zeiten die Variable "intMinutes" ausgibst anstatt "minutes"

überprüf das mal, die ausgabe is ja net drin


----------



## java_newbie (8. Jul 2004)

Die Ausgabe ist da net mit drin? Hmm also ich kopiere einfach nochmal den ganzen Code


```
<?php
/*

(...)

*/
$text = "<div id='Clock'>&</div>";
if(!$clock_flat){
	$ns -> tablerender($menu_pref['clock_caption'], "<div style='text-align:center'>".$text."</div>");
}else{
	echo $text;
}

?>
<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>
```


----------

