Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.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 - Fatal编程技术网

Php 启动&;从月份到年份的月份结束时间戳

Php 启动&;从月份到年份的月份结束时间戳,php,Php,我有以下资料: Array ( [month] => 07 [year] => 2014 ) 我想要使用上述数组的2014年7月开始和结束时间戳。使用的函数: 可能是这样的: $start_month_str = $array['year'] . '-' . $array['month'] . '-1 midnight'; $end_month_str = $start_month_str . ' + 1 month - 1 minute'; $start_mo

我有以下资料:

Array
(
    [month] => 07
    [year] => 2014
)
我想要使用上述数组的2014年7月开始和结束时间戳。

使用的函数:


可能是这样的:

$start_month_str = $array['year'] . '-' . $array['month'] . '-1 midnight';
$end_month_str = $start_month_str . ' + 1 month - 1 minute';

$start_month_stamp = strtotime($start_month_str);
$end_month_stamp = strtotime($end_month_str);


mktime()应该是你的朋友。如果您需要给定月份的结束时间戳(以检查给定时间戳是否在该月份),则可能更容易获取下个月第一个月的时间戳,并检查给定时间戳是否较小。请参见此。
$start_month_str = $array['year'] . '-' . $array['month'] . '-1 midnight';
$end_month_str = $start_month_str . ' + 1 month - 1 minute';

$start_month_stamp = strtotime($start_month_str);
$end_month_stamp = strtotime($end_month_str);