<?php
// Set the timezone to your preferred timezone
date_default_timezone_set('UTC');
// Get the current month and year
$month = date('m');
$year = date('Y');
// Get the number of days in the current month
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $month, $year);
// Create an array of dates in the current month
$dates = array();
for ($day = 1; $day <= $days_in_month; $day++) {
$date = new DateTime("$year-$month-$day");
$dates[] = $date->format('Y-m-d');
}
// Output the dates in an HTML table column
echo "<table>";
echo "<tr>";
echo "<th>Dates</th>";
echo "</tr>";
foreach ($dates as $date) {
echo "<tr>";
echo "<td>$date</td>";
echo "</tr>";
}
echo "</table>";
?>
2条答案
按热度按时间yyyllmsg1#
jhdbpxl92#