Aşağıdaki kodları bir metin editörü ile boş bir sayfa içerisine yazın ve dosyayı kaydederken uzantısını html yapın.
Dosyayı herhangi bir web tarayıcı program ile açtığınızda işletim sisteminizde yazan tarih ve saati sayfanızda görebileceksiniz.
Kod: Tümünü seç
<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="utf-8">
<title id="title">Tarih ve Saati Göster</title>
</head>
<body>
<div id="TveS">
<p id="tarih">Tarih<p>
<p id="saat">Saat<p>
</div>
</body>
<script>
function time() { let time = new Date();
document.getElementById("tarih").innerHTML = "Tarih: " + time.getDate() + "/" + (time.getMonth()+1) + "/" + time.getFullYear();
document.getElementById("saat").innerHTML = "Saat: " + time.getHours() + ":" + time.getMinutes() + ":" + time.getSeconds();
}
setInterval(time,1000);
</script>
</html>