-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
56 lines (46 loc) · 1.12 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const name=prompt("Adınızı giriniz: ");
const body=document.querySelector("body");
body.style.display="flex";
body.style.color="#dc831c";
body.style.width="100%";
body.style.height="100vh";
body.style.alignItems="center";
body.style.flexDirection="column";
const d = new Date();
let hour = d.getHours();
let second=d.getSeconds();
let minute=d.getMinutes();
let day=d.getDay();
days=["pazartesi","salı","çarşamba","perşembe","cuma","cumartesi","pazar"];
let newHour,newMinute,newSecond;
const h2=document.createElement("h2");
setInterval(function(){
second++;
if(second==59){
second=0;
minute++;
}
if(minute==59){
minute=0;
hour++;
}
if(hour==23){
hour=0;
day++;
if(day==7) day=0;
}
function formatTime(num){
return num < 10 ? "0" + num : num;
}
newSecond=formatTime(second);
newMinute=formatTime(minute);
newHour=formatTime(hour);
h2.innerHTML=`${newHour}:${newMinute}:${newSecond} ${days[day-1]}`;
},1000);
body.innerHTML=`
<div>
<h1> KODLUYORUZ</h1>
<h3>Merhaba, ${name}! Hoşgeldin</h3>
</div>
`;
body.appendChild(h2);