Prayer Times and Sehri/Iftar Time /* Style for the prayer times */ .prayer-times { background-color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); border-radius: 5px; text-align: center; margin-bottom: 20px; padding: 20px; } h1 { font-size: 2.5rem; margin-bottom: 20px; } table { margin: 20px auto; border-collapse: collapse; width: 100%; } th, td { padding: 10px; text-align: center; border-bottom: 1px solid #ddd; } th { background-color: #333; color: #fff; } tr:nth-child(even) { background-color: #f2f2f2; } /* Style for the Sehri and Iftar time */ .sehri-iftar-times { display: flex; justify-content: space-between; align-items: center; background-color: #f8f8f8; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); border-radius: 5px; text-align: center; padding: 20px; } .sehri-iftar-times div { flex: 1; margin-right: 10px; text-align: center; } .sehri-iftar-times h2 { font-size: 2rem; margin-bottom: 10px; } .sehri-iftar-times p { font-size: 1.5rem; margin: 0; } /* Style for the location button */ .location-button { background-color: #4CAF50; border: none; color: #fff; padding: 10px; border-radius: 5px; cursor: pointer; } Prayer Times Prayer Time Time Fajr - Dhuhr - Asr - Maghrib - Isha - Sehri Time - Iftar Time - Show Time As My Location // Default location is Dhaka let latitude = 23.8103; let longitude = 90.4125; // Update prayer times and Sehri/Iftar time function updateTimes() { let date = new Date(); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); // Prayer Times API let prayerTimesUrl = `https://api.aladhan.com/v1/timings/${day}-${month}-${year}?latitude=${latitude}&longitude=${longitude}&method=2`; fetch(prayerTimesUrl) .then(response => response.json()) .then(data => { let timings = data.data.timings; document.getElementById("fajr-time").innerHTML = timings.fajr; document.getElementById("dhuhr-time").innerHTML = timings.dhuhr; document.getElementById("asr-time").innerHTML = timings.asr; document.getElementById("maghrib-time").innerHTML = timings.maghrib; document.getElementById("isha-time").innerHTML = timings.isha; document.getElementById("sehri-time").innerHTML = timings.sehr; document.getElementById("iftar-time").innerHTML = timings.iftar; }) .catch(error => console.log(error)); } // Get user's location function getLocation() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { latitude = position.coords.latitude; longitude = position.coords.longitude; updateTimes(); }); } else { alert("Geolocation is not supported by this browser."); } } // Update prayer times and Sehri/Iftar time on page load updateTimes();