Я построил время молитв, используя молитвенник.оргТеперь мне нужно получить следующую молитву и сколько часов, минут, секунд осталось до предстоящей молитвы.Я конвертировал дату и время в 24 формата, чтобы можно было определять расстояния между временами и проверять, совпадает ли время между двумя моментами, тогда наступает молитва.Тем не менее, я не смог найти правильный.
Пример времени молитвы (Время сейчас 6:50 - Фаджр 3:05 - Дхур 13: 10 ... и т. Д.) Я перевел время24 формиата депандируют в AM или PM.
// Update the count down every 1 second
var x = setInterval(function() {
if (countDownDate > IshaTimeAF && countDownDate <= FajrTimeAF) {
// Find the distance between now an the count down date
var distance = FajrTimeAF - countDownDate;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("ComingSoon").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
//display = document.querySelector('#ComingSoon') + "UPCOMING PRAYER FAJR";
}
else if (countDownDate > FajrTimeAF && countDownDate <= DhuhrTimeAF) {
// Find the distance between now an the count down date
var distance = DhuhrTimeAF - countDownDate;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("ComingSoon").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
//display = document.querySelector('#ComingSoon') + " UPCOMING PRAYER DHUHR";
}
else if (countDownDate > DhuhrTimeAF && countDownDate <= AsrTimeAF) {
// Find the distance between now an the count down date
var distance = AsrTimeAF - countDownDatenow;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("ComingSoon").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
// display = document.querySelector('#ComingSoon') + "UPCOMING PRAYER ASR";
}
else if (countDownDate > AsrTimeAF && countDownDate <= MaghribTimeAF) {
// Find the distance between now an the count down date
// Find the distance between now an the count down date
var distance = countDownDatenow - MaghribTimeAF;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("ComingSoon").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
//display = document.querySelector('#ComingSoon') + " UPCOMING PRAYER MAGHRIB";
}
else if (countDownDate > MaghribTimeAF && countDownDate <= IshaTimeAF) {
// Find the distance between now an the count down date
var distance = countDownDate - IshaTimeAF;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result in an element with id="demo"
document.getElementById("ComingSoon").innerHTML = hours + "h " + minutes + "m " + seconds + "s ";
// display = document.querySelector('#ComingSoon') + " UPCOMING PRAYER ISHA";
}
// If the count down is over, write some text
if (distance < 0) {
clearInterval(x);
// document.getElementById("demo").innerHTML = "EXPIRED";
}
}, 1000);