-2
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を使用して、2つの日付の差を計算する方法?](http://stackoverflow.com/questions/676824/how-to-calculate-the-difference-between-two-dates -using-php) – currarpickt
これは7年前のことですが、PHPのバージョンは古すぎます。 –