<!DOCTYPE html>
<html>
<head>
<title>Date Difference</title>
</head>
<body>
<h1>Date Difference Calculator</h1>
<form method="post" action="">
<label for="birthdate">Select your birth date:</label>
<select name="birthdate" id="birthdate">
<?php
// Generate the dropdown options for dates
for ($day = 1; $day <= 31; $day++) {
echo '<option value="' . $day . '">' . $day . '</option>';
}
?>
</select>
<select name="birthmonth">
<?php
// Generate the dropdown options for months
$months = [
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December'
];
foreach ($months as $monthNumber => $monthName) {
echo '<option value="' . $monthNumber . '">' . $monthName . '</option>';
}
?>
</select>
<select name="birthyear">
<?php
// Generate the dropdown options for years
$currentYear = date('Y');
for ($year = $currentYear; $year >= ($currentYear - 100); $year--) {
echo '<option value="' . $year . '">' . $year . '</option>';
}
?>
</select>
<br><br>
<input type="submit" value="Check Eligibility">
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Retrieve the selected birth date
$day = $_POST['birthdate'];
$month = $_POST['birthmonth'];
$year = $_POST['birthyear'];
// Create the selected birth date and January 1, 2023 as DateTime objects
$selectedDate = new DateTime($year . '-' . $month . '-' . $day);
$january1_2023 = new DateTime('2023-01-01');
// Calculate the difference in days
$difference = $selectedDate->diff($january1_2023)->days;
// Check eligibility and display the result
if ($difference < 7300) {
echo "<p>You are not eligible.</p>";
} else {
echo "<p>You are eligible.</p>";
}
}
?>
</body>
</html>
To embed this program on your website, copy the following code and paste it into your website's HTML: