This is a little more than others, but the idea is the same. I did this on a page that I could try / check, so this is a form instead of a function. several modifications, and you have a model.
<?PHP
if (!isset($_REQUEST['start']) || empty($_REQUEST['start'])) {
echo "Enter a date to check for.<br>\n";
} else {
$start = $_REQUEST['start'];
$startYear = (int)substr($start,0,4);
$start_date = date("M d, Y", mktime(0,0,0,substr($start,4,2),substr($start,6,2),substr($start,0,4)));
$ac_start_date = date("M d, Y", mktime(0,0,0,'8','1',$startYear));
if ($start_date < $ac_start_date) {
$AC_Year = ($startYear-1)."/".($startYear);
} else {
$AC_Year = ($startYear)." / ".($startYear+1);
}
echo "Academic Year for ".$start." = ".$AC_Year.".<br>\n<br>\n";
}
?>
<form name="aychk">
<div style="float:left;">
Student start date
</div>
<div style="float:left;">
<input name="start" type="text" placeholder="YYYYMMDD" />
</div>
<div style="clear:both;"></div>
<input type="submit" value="Check">
</form>
but I think it works ...
source
share