-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsholat.js
42 lines (37 loc) · 978 Bytes
/
sholat.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
// ambil tanggal
const getDate = new Date();
const getYear = getDate.getFullYear();
const getMont = getDate.getMonth() + 1;
const getDay = getDate.getDate();
function bulan(){
if(getMont < 10 ){
bulan = `0${getMont}`;
}else{
bulan = getMont
}
return bulan
}
// ambil hari
function hari(){
if (getDay < 10){
hari = `0${getDay}`;
}else {
hari = getDay;
}
return hari;
}
const tanggal = `${getYear}-${bulan()}-${hari()}`;
function getJadwalSholat() {
fetch('https://api.myquran.com/v2/sholat/jadwal/0809/' + tanggal)
.then(res => res.json())
.then ( data => {
const jadwal = data.data.jadwal
// console.log(jadwal)
document.getElementById('subuh').textContent = jadwal.subuh
document.getElementById('dzuhur').textContent = jadwal.dzuhur
document.getElementById('ashar').textContent = jadwal.ashar
document.getElementById('maghrib').textContent = jadwal.maghrib
document.getElementById('isya').textContent = jadwal.isya
})
}
getJadwalSholat()