Hi, I am trying to add a date range to show the Ramadan calender but I am unable to fix it. This is my code and it's working perfectly to show the whole month's prayer time. I want to show Ramadan dates.
// Month ramadan Time
$currentYear = date("Y");
$currentMonth = date("m");
$currentDate = date("d M Y"); // Current date in the same format as the API response
// Set the API URL
try {
$month_times_data = json_decode(file_get_contents("http://api.aladhan.com/v1/calendarByAddress/{$currentYear}/{$currentMonth}?address={$city},%20{$country}&method={$method}&school={$school}&midnightMode={$midnightMode}&latitudeAdjustmentMethod={$latitudeAdjustmentMethod}"), true);
if (isset($month_times_data['data'])) {
// Your code for processing the data here
} else {
echo "No data available for the selected location and method.";
}
} catch (Exception $e) {
echo "An error occurred while fetching data from the API: " . $e->getMessage();
}
// Check if data was successfully retrieved
if (isset($month_times_data['data'])) {
$data = $month_times_data['data'];
// Create a table to display ramadan times
echo '<table class="table table-bordered table-striped table-hover">';
echo '<tr class="table-dark"><th>Day</th><th>Date</th><th>Sehri</th><th>Iftaar</th></tr>';
// Loop through the data and display ramadan times in the table
$dayCounter = 1;
foreach ($data as $day) {
$date = $day['date']['readable'];
$fajr = convertToAmPm(substr($day['timings']['Fajr'], 0, 5)); // Extract HH:MM and convert
$maghrib = convertToAmPm(substr($day['timings']['Maghrib'], 0, 5)); // Extract HH:MM and convert
// Check if the date matches the current date and apply a CSS class for highlighting
$highlightClass = ($date === $currentDate) ? 'highlight-row' : '';
echo "<tr class='$highlightClass'><td>{$dayCounter}</td><td>$date</td><td>$fajr</td><td>$maghrib</td></tr>";
$dayCounter++;
}
echo '</table>';
} else {
echo "Error fetching data from the API.";
}
?>`