Php 我怎样才能得到这个月的最后一天';时间戳?
我将当前unix时间戳存储在变量Php 我怎样才能得到这个月的最后一天';时间戳?,php,timestamp,Php,Timestamp,我将当前unix时间戳存储在变量$current\u 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 = da
$current\u 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')
您还可以将其用作其他相对日期/时间格式的参考:
此
strotime(“的最后一天”)
将为您提供当月最后一天的时间戳。此处引用:或者,如果您特别希望它与当前月份相关,strotime(“本月的最后一天”)