我将当前的unix时间戳存储在变量$current_time
中。使用此变量,我想确切了解当前月份最后一天的时间戳。
我如何在PHP 5.4 +中执行此操作?
答案 0 :(得分:1)
这是一个有效的例子:
// 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