-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeColor.js
37 lines (32 loc) · 942 Bytes
/
timeColor.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
function backgroundColor1() {
var blue = document.getElementById("newColor");
blue.style.backgroundColor = "royalblue";
}
function backgroundColor2() {
var blue = document.getElementById("newColor");
blue.style.backgroundColor = "mediumorchid";
}
function getTime() {
var timeHere = document.getElementById('timeHere');
fetch ("http://worldtimeapi.org/api/ip", {
method: "GET",
})
.then((resp) => {
console.log(resp);
resp.json().then(json => timeHere.innerText = json.datetime)})
.catch((err) => {
console.error(err);
})
}
function getZone() {
var timeHere = document.getElementById('timeZone');
fetch ("http://worldtimeapi.org/api/ip", {
method: "GET",
})
.then((resp) => {
console.log(resp);
resp.json().then(json => timeZone.innerText = json.timezone)})
.catch((err) => {
console.error(err);
})
}