我想,以确定是否给定的日期$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'。 –