返回时间戳差值部分,年、月、日
function get_date_diff($startstamp, $endstamp, $return = 'm')
{
$y = date('Y', $endstamp) - date('Y', $startstamp);
$m = date('m', $endstamp) - date('m', $startstamp);
switch ($return) {
case 'y':
if ($y <= 1) {
$y = $m / 12;
}
$string = $y;
break;
case 'm':
$string = $y * 12 + $m;
break;
case 'd':
$string = ($endstamp - $startstamp) / 86400;
break;
}
return $string;
}
标签:startstamp,endstamp,函数,date,return,php,常用工具
From: https://www.cnblogs.com/sunr/p/16799152.html