如果我有兩個日期,21/05/2010和23/05/2010,我怎麼才能知道22/05/2006上午07點16分存在於它們之間?日期範圍的問題
我正在使用下面的代碼來計算最小/最大日期,然後將選擇清除表中的所有記錄來更新它們。
$today = date('l');
if($today == 'Wednesday'){
$min = date('d/m/Y', strtotime('0 days'));
$max = date('d/m/Y', strtotime('+6 days'));
}else if($today == 'Thursday'){
$min = date('d/m/Y', strtotime('-1 days'));
$max = date('d/m/Y', strtotime('+5 days'));
}else if($today == 'Friday'){
$min = date('d/m/Y', strtotime('-2 days'));
$max = date('d/m/Y', strtotime('+4 days'));
}else if($today == 'Saturday'){
$min = date('d/m/Y', strtotime('-3 days'));
$max = date('d/m/Y', strtotime('+3 days'));
}else if($today == 'Sunday'){
$min = date('d/m/Y', strtotime('-4 days'));
$max = date('d/m/Y', strtotime('+2 days'));
}else if($today == 'Monday'){
$min = date('d/m/Y', strtotime('-5 days'));
$max = date('d/m/Y', strtotime('+1 days'));
}else if($today == 'Tuesday'){
$min = date('d/m/Y', strtotime('-6 days'));
$max = date('d/m/Y', strtotime('0 days'));
}
我收到以下錯誤「致命錯誤:未捕獲的異常'異常'消息'DateTime :: __ construct()[datetime.--construct]:無法解析位置0(1)處的時間字符串(15/12/2010):意外字符'在C:\ xampp \ htdocs \ keypad \ pay.php中:269堆棧跟蹤:#0 C:\ xampp \ htdocs \ keypad \ pay.php(269):DateTime - > __ construct('15/12/2010' 1 {main}拋出C:\ xampp \ htdocs \ keypad \ pay.php 269行「 – methuselah 2010-12-20 16:31:07
好的,謝謝我要去測試編輯的代碼 – methuselah 2010-12-20 16:31:49
我還是得到錯誤:致命錯誤:未捕獲異常'異常' DateTime :: __ construct()[datetime.--construct]:無法解析位置0(2)處的時間字符串(21/05/2010):C:\ xampp \ htdocs \ keypad \ pay.php中的意外字符:269堆棧跟蹤: #0 C:\ xampp \ htdocs \ keypad \ pay.php(269):DateTime - > __ construct('21/05/2010')#1 {main}拋出C:\ xampp \ htdocs \ keypad \ pay.php在線269 – methuselah 2010-12-20 16:34:05