【发布时间】:2012-11-29 05:35:54
【问题描述】:
在 PHP 中,我试图获取上个月的最后一天。 例如,今天是 2012 年 12 月 11 日。所以我想抓住的日期是 11 月 30 日。
这是我目前正在尝试做的:
//this grabs the last daye of this month
$current_month = date('Y-m-t',strtotime('today'));
//this should grab November 30th.
$last_month = date("F, Y",strtotime($current_month." -1 month ")
它没有抓住 11 月 30 日,而是抓住了 12 月 1 日。似乎“-1 个月”只是减去 30 天。
如何正确抓取上个月的最后一天?
【问题讨论】: