如何获取月份时间戳的最后一天


How can I get the last day of the month's timestamp?

我将当前的 unix 时间戳存储在变量 $current_time 中。使用此变量,我想确切地找出当前月份最后一天的时间戳。

如何在 PHP 5.4+ 中执行此操作?

这是一个工作示例:

// this is if your $current_time is not within the current month (although the code below is valid for every single month and every single timestamp)
$month = date("M", $current_time);
$last_day_timestamp = strtotime('last day of ' . $month);
echo date("d-m-Y", $last_day_timestamp);
// if your $current_time is within the current month
$last_day_timestamp_of_this_month = strtotime('last day of this month')

您也可以将其用作其他相对日期/时间格式的参考:http://php.net/manual/en/datetime.formats.relative.php