Certainly! You want to loop through all days in a month and highlight the current day (today) by setting a special class in your HTML output.
Here's a clean way to do this in PHP:
<?php
$month = date('m'); // current month
$year = date('Y'); // current year
$days = cal_days_in_month(CAL_GREGORIAN, $month, $year); // total days in month
$today = date('j'); // current day of the month (no leading zeros)
for ($d = 1; $d <= $days; $d++) {
// Check if this day is today
$class = ($d == $today) ? 'class="today"' : '';
echo "<span $class>$d</span> ";
}
?>
Explanation:
$daysgets the total number of days in the current month.$todaygets today's day number.- The loop goes from 1 to
$days. - If
$dmatches$today, it adds aclass="today"to the<span>. - Otherwise, it outputs a normal
<span>.
You can style the .today class in your CSS as needed.
Let me know if you need this adapted for a specific month/year or in a Blade template!