Display prayer times from script

Hello

I’m a beginner and i would like your help with the following script http://praytimes.org/code/git/?a=tree&p=PrayTimes&hb=HEAD&f=v1/php

I would like to display the prayer times for current day and for the whole of current month. What code is required to do that? Thanks

You want a message popup that appears at certain times of the day? Your request isn’t clear enough.

Thanks for the reply. I would like to display the times on my wordpress website, something like " get the timestamp and display the prayer times for today" and then i set the latitude and longitude and calculation method.

If i get that right, i would like to display prayer times for the whole month as well, in a table. I hope that is more clearer, sorry i don’t know the right terminology to use.

I guess my question is, how can i use this sample code to output the times? I have no clue where to begin to be honest

//------------------------- Sample Usage --------------------------


    $prayTime->setCalcMethod($prayTime->ISNA);
    $times = $prayTime->getPrayerTimes(time(), 43, -80, -5);
    print('Sunrise = '. $times[1]);


*/

start with the data you want to build your script upon, dates from today until 30 days in the future. so you can use an instance of DateTime wichich defaults to now and then modify() it with +1 day within a loop. Looks like the class requires the date in the format of getTimestamp()

It was my understanding that the script takes care of all that heavy lifting as it calculates the times for the desired latitude and longitude. I might be wrong though.

Please take a look at this from the sample.php to see if it can help me

<?php

	$prayTime = new PrayTime($method);

	$date = strtotime($year. '-1-1');
	$endDate = strtotime(($year+ 1). '-1-1');

	while ($date < $endDate)
	{
		$times = $prayTime->getPrayerTimes($date, $latitude, $longitude, $timeZone);
		$day = date('M d', $date);
		print $day. "\t". implode("\t", $times). "\n";
		$date += 24* 60* 60;  // next day
	}

?>

Thanks

just have a look at the function signature, it requires a date. this date (or all dates for a given time range) can be calculated with the steps i posted (could be improved by using DatePeriod). Within the example you just have to adjust start and end times.

1 Like

Thanks everybody for the replies. This is way above my head for now and i will come back to it after some more reading.

Keep sharin the knowledge !

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.