我希望显示某个月份中各天的日期。我应该如何做呢?我只能输入月份并显示所有日期。
<html>
<body>
<form method="POST">
Day (Eg: Sunday) : <input name="day" required type="text" size="30" style="height:30px;" /> <br/><br/>
Month (Eg: 7) : <input name="month" required type="text" size="30" style="height:30px;" /> <br/><br/>
<input name="Submit" type="submit" value="Log In" style="background-color: #2E9AFE; border: 1px solid #084B8A; padding: 1px 3px; color:#fff; width:60px; height:30px;" />
</form>
<?php
$day=$_POST['day'];
$month=$_POST['month'];
function getDates($y, $m)
{
return new DatePeriod(
new DateTime("first sunday of $y-$m"),
DateInterval::createFromDateString('next sunday'),
new DateTime("last day of $y-$m")
);
}
foreach (getDates(2015, $month) as $getDay) {
echo $getDay->format("l, Y-m-d\n");
}
?>
</body>
</html>