hawkontvn Posted November 6, 2009 Share Posted November 6, 2009 Hey. I learned PHP just recently, and I just managed to pull out making this calendar, but I wonder how I can make today's date appear in <b></b>. Here's the code: <?php echo "<style>.cal { float: right; }</style>"; // Get today's date $date = time(); // Set day, month, and year in seperate variables $day = date('d', $date); $month = date('m', $date); $year = date('Y', $date); // Generate the first day of the month $first_day = mktime(0,0,0,$month, 1, $year); // Get the month name $title = date('F', $first_day); // Find out what day of the week the first day of the month falls on $day_of_week = date('D', $first_day); // Blank days before $day_of_week (0 if Sunday) switch($day_of_week) { case "Son": $blank = 0; break; case "Man": $blank = 1; break; case "Tir": $blank = 2; break; case "Ons": $blank = 3; break; case "Tor": $blank = 4; break; case "Fre": $blank = 5; break; case "Lor": $blank = 6; break; } // Determine number of days in current month $days_in_month = cal_days_in_month(0, $month, $year); // Building table heads echo "<table border='1' width='194' class='cal'>"; echo "<tr><th colspan='7'> $title $year </th></tr>"; echo "<tr><td width='42'>S</td><td width='42'>M</td> <td width='42'>T</td><td width='42'>O</td><td width='42'>T</td> <td width='42'>F</td><td width='42'>L</td></tr>"; // Count the days in the week, up to 7 $day_count = 1; echo "<tr>"; // Blank days first while ($blank > 0) { echo "<td></td>"; $blank = $blank-1; $day_count++; } // Set the first day of the month to 1 $day_num = 1; // Count all the days in the month while ($day_num <= $days_in_month) { echo "<td> $day_num </td>"; $day_num++; $day_count++; // New row for every week if ($day_count > 7) { echo "</tr><tr>"; $day_count = 1; } } // End of month, blank days (if needed) while ($day_count > 1 && $day_count <= 7) { echo "<td> </td>"; $day_count++; } echo "<tr></table>"; Thanks Link to comment https://forums.phpfreaks.com/topic/180596-php-calendar-making-today-appear-in-bold/ Share on other sites More sharing options...
Mchl Posted November 6, 2009 Share Posted November 6, 2009 Like this for example // Count all the days in the month while ($day_num <= $days_in_month) { if ($day != $day_num) { echo "<td> $day_num </td>"; } else { echo "<td><b> $day_num </b></td>"; } $day_num++; $day_count++; Link to comment https://forums.phpfreaks.com/topic/180596-php-calendar-making-today-appear-in-bold/#findComment-952812 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.