如何使用php显示从当前月份开始到结束的日期?

如何使用php显示从当前月份开始到结束的日期?,php,html,Php,Html,我可以从mysql中存储的数据中显示从开始日期到结束日期的日期,但我希望以 一, 2. 3. 4. . . . . . 三十一 这可能吗?请参阅PHPcal\u days\u in\u month 此函数将返回指定日历的月份天数 int-calu-days(int$calendar,int$month,int$year) 举个例子: $number = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31 echo "There were {$num

我可以从mysql中存储的数据中显示从开始日期到结束日期的日期,但我希望以

一, 2. 3. 4. . . . . . 三十一


这可能吗?

请参阅PHP
cal\u days\u in\u month

此函数将返回指定日历的月份天数

int-calu-days(int$calendar,int$month,int$year)

举个例子:

$number = cal_days_in_month(CAL_GREGORIAN, 8, 2003); // 31
echo "There were {$number} days in August 2003";

使用循环来显示天数计数

如果您想要月内的所有天数,请尝试此循环,其中日期(“t”)为您提供月内最后一天的数字,我们知道第一天始终为1

$last = date("t");
for($i=1; $i<= $last; $i++) echo "$i "; 
$last=日期(“t”);

对于PHP部分的($i=1;$i),这可能会帮助您:

// Get the current date
$today = getdate();

// Get the number of days in current month
$days_in_month = cal_days_in_month(CAL_GREGORIAN, $today['mon'], $today['year']); 

// Print the dates
for ($i = 1; $i <= $days_in_month; $i++) {
  echo ' ' . $i;
}
//获取当前日期
$today=getdate();
//获取当前月份的天数
$days_in_month=cal_days_in_month(cal_GREGORIAN,$today['mon'],$today['year');
//打印日期
对于($i=1;$i
是的。这是可能的。
请使用下面的php代码。它可以用于PHP4.1及更高版本。

不要害羞,与我们分享您的尝试;)我没有尝试过任何东西,当我思考它时,我没有得到解决方案,所以我问
yes. it is possible.
please, use below php code. it can work for php 4.1 and higher.
<?php
$number = cal_days_in_month(CAL_GREGORIAN, date('m'), date('Y'));
for($i=1;$i<=$number;$i++)
    echo $i.'<br>';
?>