我写了一些代码来comapre日期,在这里我得到的问题是当我输入日期为2012年/ mar/23给输出一些正确的时间,有些时候wrong.when我输入日期为2012/03/23给出的输出还有一些错误,有时错误,我可以解决这个问题吗?日期比较
<?php
$month = 2;
$year = 2012;
$saturday = strtotime('First Saturday '.date('F o', mktime(0,0,0, $month, 1, $year)));
echo date('Y/M/d', $saturday);
$sat1 = strtotime($saturday);
echo "<br/>";
$season1 = strtotime ('+12 week' , $saturday);
$season2= date ('Y/M/d' , $season1);
echo $season2;
$season = strtotime($season1);
echo "<br/>";
$date = $_POST["date"];
echo $date;
$date1 = strtotime($date);
echo "<br/>";
$abc = strtotime ('+1 week' , $season1);
$abc = date ('Y/M/d', $abc);
echo "<br/>";
echo $abc;
$abc1 = strtotime($abc);
if ($date1 <= $abc1)
{
if ($date1 <= $season)
{
echo "League already opened";
}
else if($date1 > $season)
{
echo "league successfully closed";
}
}
else
{
echo "league 1 closed";
}
if(!isset($POST['submit'])) {
?>
<form method="post" action=" ">
<label>enter date in YYYY/MM/DD format</label>
<input type="text" name="date" size="10" />
<input type="submit" value="submit" name="submit">
</form>
<?
}
?>
和输出它示出了在如果condition.before提交表单
你需要缩进你的代码! – ThiefMaster
任何人都可以告诉上述代码的解决方案?。感谢提前 – leela