-2
我想知道如何找到两个日期的差异。我从表单中获取startDate和endDate。现在我想查找当前日期和startDate或endDate的区别。在php中找到日期差异
echo $startDate = $startYear.'-'.$startMonth.'-'.$startDay.'<br>';
echo $endDate = $endYear.'-'.$endMonth.'-'.$endDay;
$_SESSION['startDate'] = $startDate;
$_SESSION['endDate'] = $endDate;
$_SESSION['team'] = $team;
header('location:test.php');
test.php的
date_default_timezone_set('Asia/Kuala_Lumpur');
echo $startDate = $_SESSION['startDate'];
$date2=date_create(date('Y/m/d'));
$diff=date_diff($startDate,$date2);
echo $diff->format("%R%a days");
的可能的复制[如何计算使用PHP的两个日期之间的差异?](http://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates -using-php) – currarpickt
那是7年前的版本,php太旧了。 –