PHP错误的日期时间(DST)?

PHP错误的日期时间(DST)?,php,datetime,Php,Datetime,我必须返回本月和上个月 今天,3月31日,这两个月是一样的。(DST) 两者都返回“2014-03” 有什么建议吗?这是因为二月的天数较少,所以你需要应用一些日期魔法: $prevYearMonth = $now->modify('first day of last month')->format('Y-m'); $prevYearMonth = $now->modify('first day of last month')->format('Y-m');

我必须返回本月和上个月

今天,3月31日,这两个月是一样的。(DST)

两者都返回“2014-03”


有什么建议吗?

这是因为二月的天数较少,所以你需要应用一些日期魔法:

$prevYearMonth = $now->modify('first day of last month')->format('Y-m');
$prevYearMonth = $now->modify('first day of last month')->format('Y-m');