Webmester honlap - Dátum és idő
Megmutatja az aktuális időt és dátumot :
<HEAD>-ben:
<script Language="JavaScript">
<!--
var IdoString, DatumsString;
function IdoDatum ()
{
Most = new Date();
Ora = Most.getHours();
Perc = Most.getMinutes();
Masodperc = Most.getSeconds();
IdoString = "" + Ora;
IdoString += ((Perc < 10) ? ":0" : ":") + Perc;
IdoString += ((Masodperc < 10) ? ":0" : ":") + Masodperc;
document.Orak.Ido.value = IdoString;
Nap = Most.getDate();
Honap = Most.getMonth()+1;
ev = Most.getYear();
DatumsString = "" + Nap;
DatumsString += ((Honap<10) ? ".0" : ".") + Honap;
DatumsString += "." + ev;
document.Orak.Datum.value = DatumsString;
Timer = setTimeout("IdoDatum()", 1000);
}
// -->
</script>
<BODY>-ban:
<body onload=""IdoDatum()">
<form name="Orak">
<pre>Idő <input type="text" name="Ido" size="8" value>
Dátum <input type="text" name="Datum" size="8" value></pre>
</form>
</body>
https://www.ats-group.net/webmester/javascript-tippek/js20.shtml" target="_blank" onclick="window.open('js20.shtml';,'fenster','width=400,height=160'); return false">bemutató
Tartalom: