其他教程

其他教程

Products

当前位置:首页 > 其他教程 >

php计算指定时间段内的天数

GG网络技术分享 2025-03-18 16:17 0


function _getCountDays($sTime, $eTime)

{

$startDt = getdate($sTime);

$endDt = getdate($eTime);

$sUTime = mktime(12, 0, 0, $startDt[\'mon\'], $startDt[\'mday\'], $startDt[\'year\']);

$eUTime = mktime(12, 0, 0, $endDt[\'mon\'], $endDt[\'mday\'], $endDt[\'year\']);

return round(abs($sUTime - $eUTime) / 86400);

}

$sTime = strtotime(\'2021-12-26\');

$eTime = strtotime(\'2022-1-25\');

echo _getCountDays($sTime,$eTime)+24;

标签: 时间段内 天数

提交需求或反馈

Demand feedback