.widget{ max-width:500px; margin:auto; background:#fff; padding:25px; border-radius:16px; box-shadow:0 2px 12px rgba(0,0,0,0.08); font-family:'Plus Jakarta Sans',sans-serif; text-align:center; } h1{ font-size:20px; margin-bottom:15px; color:#052e16; } .box{ font-size:18px; margin:12px 0; font-weight:700; } .gregorian { font-size: 14px; color: #6b7280; margin-bottom: 15px; font-weight: 500; } .pak{color:#047857;} .world{color:#1d4ed8;} .time{color:#b45309;font-size:16px;margin-top:10px;} Islamic Date Today Pakistan Islamic Date: Calculating... World Islamic Date: Calculating... function updateWidget() { // 1. Handle live Pakistan Time and Gregorian Date display const now = new Date(); // Formatting current Gregorian date (e.g., "Sunday, 21 June 2026") const dateOptions = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric', timeZone: 'Asia/Karachi' }; document.getElementById("gregorianDate").innerHTML = now.toLocaleDateString('en-PK', dateOptions); // Live clock update document.getElementById("time").innerHTML = "PKT Live Time: " + now.toLocaleTimeString('en-PK', { timeZone: 'Asia/Karachi' }); // 2. Dynamic Islamic Date Calculation logic // Using June 21, 2026 as our benchmark base alignment date (5 Muharram PK / 6 Muharram World) const baseGregorianDate = new Date('2026-06-21T00:00:00+05:00'); const basePakIslamicDay = 5; const baseWorldIslamicDay = 6; // Get difference in total calendar days between today and our base date const msPerDay = 24 * 60 * 60 * 1000; // Create stripped dates to compare purely calendar days independently of current execution hour const dateNowPK = new Date(now.toLocaleString('en-US', { timeZone: 'Asia/Karachi' })); const dateBasePK = new Date(baseGregorianDate.toLocaleString('en-US', { timeZone: 'Asia/Karachi' })); dateNowPK.setHours(0,0,0,0); dateBasePK.setHours(0,0,0,0); const dayDifference = Math.round((dateNowPK - dateBasePK) / msPerDay); // Simple temporary cycle tracker for Muharram (up to 30 days) // For long-term 12-month automation, tracking month lengths is optimal, but this reliably covers Muharram 1448 let currentPakDay = basePakIslamicDay + dayDifference; let currentWorldDay = baseWorldIslamicDay + dayDifference; let currentMonth = "Muharram"; let currentYear = 1448; // Reset loop if day calculation crosses into Safar (Assuming 30 days for Muharram) if (currentPakDay > 30) { currentPakDay = currentPakDay - 30; // logic for next month if you need expansion later } if (currentWorldDay > 30) { currentWorldDay = currentWorldDay - 30; } // Set updated calculations directly to elements document.getElementById("pakDate").innerHTML = `Pakistan Islamic Date: ${currentPakDay} ${currentMonth} ${currentYear} AH`; document.getElementById("worldDate").innerHTML = `World Islamic Date: ${currentWorldDay} ${currentMonth} ${currentYear} AH`; } // Initialize on page run and configure execution loops updateWidget(); setInterval(updateWidget, 1000);