0

i try to generate praytime with alarm, but...

this my code

<script type="text/javascript" src="assets/js/PrayTimes.js"></script>
<script type="text/javascript">
     var date = new Date(); // today
     prayTimes.tune( {maghrib: +176} );
     var times = prayTimes.getTimes(new Date(), [-6.1333, 106.75, 10], +7);
     var maghrib = ['maghrib'];
     var wakmag = times[maghrib];
</script>

and

<?php
date_default_timezone_set('Asia/Jakarta');
$time=date('H:i');

$alarm="<script>document.write(wakmag);</script>";

echo" $time <br/><br/>
Alarm $alarm";

if ($time == "$alarm") {
echo"
  <script type='text/JavaScript'>
    window.onload = function(event) {
        $('#loadModal').modal('show');
    };
  </script>
";
} else {
echo"<br/>Wait Alarm";
}
?>

modal not show up. but if i tag

$alarm="21:00";

modal show up

any one help me ?

  • 3
    `$alarm="";` - this just assigns this _text_ to that variable, it does not execute it as JavaScript. – CBroe Feb 24 '21 at 14:30
  • 5
    This sounds like you still lack some very basic understanding of how things on the web work in general, so you should go and have a good, thorough read of [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming) first of all. – CBroe Feb 24 '21 at 14:30
  • @CBroe and how to execute ? – Mang Keno Feb 24 '21 at 14:34
  • 2
    You can not “execute” this on the PHP side, that makes no sense to begin with. If you have a value that you can only determine on the client side, and you need access to it in PHP - then you need to make a new request first, to _send_ that value from the client, to the server. I think we can fairly assume that you did not read that whole question & discussion I referred you to in under five minutes - so go and spend some actual time on that first of all, please, so that you _get_ an understanding of these essential basics. – CBroe Feb 24 '21 at 14:40
  • @CBroe i was read that q&d and i try to remove php code and add javascript code with this if (date == wakmag) { window.onload = function(event) { $('#loadModal').modal('show'); }; } and the modal not show up – Mang Keno Feb 24 '21 at 15:06

0 Answers0