嗨,我使用php存储了一个从表单中获取的日期,现在我想检查日期是否在季节中。我编写的代码如下:
$year = 2012;
$month1 = $_POST["month1"];
$date = $_POST["date"];
$result = "{$year}/{$month1}/{$date}";
echo $result;
现在
// finding first saturday in febraury
$saturday = strtotime('First Saturday '.date('F o', mktime(0,0,0, $month, 1, $year)));
echo "this is the first saturday in the given year:";
echo date('Y/m/d', $saturday);
// calculating first 12 weeks after the first saturday
echo "<br/>";
$season1 = strtotime ( '+12 week' , $saturday);
echo "<br/>this is the first season:";
echo date('Y/m/d', $season1);
echo "<br/>";
// calculating the one week gap after the first 12 weeks
$season2 = strtotime ('+1 week' , $season1);
echo "<br/>this is the first week break:";
echo date('Y/m/d', $season2);
echo "<br/>";
在这里我需要做的是检查用户给出的日期是在第 1 季还是第 2 季..为此我尝试了
if ($result <= $season1)
{
echo "League yet to be opened";
}
else
{
echo "league 1 is opened";
}
但是这里没有检查条件,同样我需要检查用户输入的日期有 8 个季节我该怎么做.. 非常感谢任何帮助.. 提前谢谢..