我寫了一些代碼來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