Mit diesem Code wird die Uhrzeit und das Datum angezeigt:
Code
<script language=javaScript>
function chkFormular()
{
if(window.document.Ftime.text.value == "") {
alert("Textfeld ist leer.");
document.Ftime.text.focus();
return false;
}
}
</script>
<body bgcolor=lightblue>
<head><script Language="JavaScript">
<!--
var TimeString, DateString;
function showTimeDate ()
{
Now = new Date();
Hours = Now.getHours();
Minutes = Now.getMinutes();
Seconds = Now.getSeconds();
TimeString = "" + Hours;
TimeString += ((Minutes < 10) ? ":0" : ":") + Minutes;
TimeString += ((Seconds < 10) ? ":0" : ":") + Seconds;
document.Ftime.inpTime.value = TimeString;
Day = Now.getDate();
Month = Now.getMonth()+1;
Year = Now.getYear();
DateString = "" + Day;
DateString += ((Month<10) ? ".0" : ".") + Month;
DateString += "." + Year;
document.Ftime.inpDate.value = DateString;
Timer = setTimeout("showTimeDate()", 1000);
}
// -->
</script>
<body onLoad="showTimeDate()">
<form name=Ftime>
<input type=text name=inpTime size=8 value>
<input type=text name=inpDate size=8 value>
</form>
Alles anzeigen
ABER!!! Bei einstelligen Stunden (0,1,2,3) wird nur eine Zahl angezeigt und nicht (00,01,02,03)! Was muss ich ändern, dass da z.B. 00:59 steht??