29-03-26, 12:48 AM
(29-03-26, 12:05 AM)nnnjk كتب : اجعله على سبيل المثال وقت صلاة الفجر فقط
يبدوا بحاجة كود php يقوم بتحويل وقت معين مثلا 03:15 الى عدد ثواني
لا لا ليس هذاا المقصد
يمكن بالفعل اظهار التنبيه بوقت معين
لكن سؤالي حتى اللحظة هل تقصد بدون تحديث الصفحه
تريد تنفيذ التنبيه دون تشغيل المتصفح ؟
ام انك تقصد عدم تحديث الصفحة بكل ثانيه ضمن نفس التوقيت
PHP كود :
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<title>تنبيه بمواقيت الصلاة</title>
<style>
#overlay {
display: none;
position: fixed;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.5);
top: 0;
left: 0;
}
#popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: #fff;
padding: 20px;
border-radius: 10px;
text-align: center;
}
#countdown {
font-size: 18px;
margin-top: 20px;
text-align: center;
}
button {
margin-top: 10px;
}
</style>
</head>
<body>
<div id="overlay"></div>
<div id="popup">
<h3>تنبيه صلاة الفجر</h3>
<p>حان الآن موعد الصلاة</p>
<button onclick="closePopup()">إغلاق</button>
</div>
<div id="countdown"></div>
<script>
const fajrTime = "03:15";
let shown = false;
function updateCountdown() {
let now = new Date();
let [hour, minute] = fajrTime.split(":");
let fajrDate = new Date();
fajrDate.setHours(parseInt(hour));
fajrDate.setMinutes(parseInt(minute));
fajrDate.setSeconds(0);
if (now > fajrDate) {
fajrDate.setDate(fajrDate.getDate() + 1);
}
let diff = fajrDate - now;
let hours = Math.floor(diff / 1000 / 60 / 60);
let minutes = Math.floor((diff / 1000 / 60) % 60);
document.getElementById("countdown").textContent =
`الوقت المتبقي لصلاة الفجر: ${hours} ساعة، ${minutes} دقيقة`;
}
function checkFajr() {
let now = new Date();
let currentTime =
now.getHours().toString().padStart(2,'0') + ":" +
now.getMinutes().toString().padStart(2,'0');
if (currentTime === fajrTime && !shown) {
document.getElementById("popup").style.display = "block";
document.getElementById("overlay").style.display = "block";
shown = true;
}
}
function closePopup() {
document.getElementById("popup").style.display = "none";
document.getElementById("overlay").style.display = "none";
}
updateCountdown();
setInterval(() => {
updateCountdown();
checkFajr();
}, 60000);
</script>
</body>
</html>


![[صورة مرفقة: 177461173141861.gif]](https://up6.cc/2026/03/177461173141861.gif)