我需要以"Ymd"格式声明两个日期:$toDate$fromDate
$toDate代表今天的日期,而$fromDate需要比今天早4个月。

$toDate = Date('Ymd');
$fromDate = ?

如何创建$fromDate

最佳答案

使用 strtotime 的魔力:

$fromDate = date("Ymd", strtotime("-4 months"));

10-08 11:20