我想,以確定是否給定的日期$my_date
(動態)是正在顯示this week
,last week
,this month
,last month
和last 3 months
PHP如果給定的日期是日期範圍
$my_date = "29/02/2016";
$scheduled_job = strtotime($my_date);
$this_week = strtotime("first day this week");
$last_week = strtotime("last week monday");
$this_month = strtotime("first day this month");
$last_month = strtotime("first day last month");
$last_three_month = strtotime("first day -3 month");
if($scheduled_job > $this_week) {
echo 1;
}
if($scheduled_job < $this_week and $scheduled_job >= $last_week) {
echo 2;
}
if(strtotime($date_job) > $this_month) {
echo 3;
}
if($scheduled_job < $this_month and $scheduled_job >= $last_month) {
echo 4;
}
if(strtotime($date_job) > $last_three_month) {
echo 5;
}
沒有。我如何解決?
你有錯誤在$ my_date中,正確的格式爲'$ my_date =「29-02-2016」;' –
如果日期範圍不重疊,則可以使用'elseif'。 –