Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我怎样才能得到这个月的最后一天';时间戳?_Php_Timestamp - Fatal编程技术网

Php 我怎样才能得到这个月的最后一天';时间戳?

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

我将当前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 = 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(“本月的最后一天”)