我想以分钟为单位计算两个日期之间的时间,同时只包括 和 之间的时间08:00:00
,16:30:00
也不包括周六和周日。我怎样才能做到这一点?以下是我的代码,它通常只是计算两个日期之间的时间。
foreach($result as $row)
{
$sub_array = array();
$sub_array[] = floor((strtotime($row['app_2_date'])-strtotime($row['app_1_date']))/(60));
$data[] = $sub_array;
}
我已经尝试了以下代码,但仍然无法正常工作
foreach($result as $row)
{
if
(
date('H:i:s', strtotime($row['app_2_date'])) > date('H:i:s', strtotime('1970-01-01 16:30:00'))||
date('H:i:s', strtotime($row['app_2_date'])) < date('H:i:s', strtotime('1970-01-01 08:00:00'))
)
{
$sub_array[] = floor((strtotime($row['app_3_date'])-strtotime($row['app_2_date']))/(60))-(15.5*60);
}
else
{
$sub_array[] = floor((strtotime($row['app_3_date'])-strtotime($row['app_2_date']))/(60));
}
}