I am trying to write a script that would work out the current academic year.
Academic year starts on Aug 1st every year.
How can i work out which Academic year we are in based on the current date.
ie 31st July 2012 (20120631) would work out as 2011/2012
13th Aug 2012 (20120801) would work out as 2012/2013
At the moment this is what I have, but its not very good as i dont want to define the dates and it does not return the correct academic year just the originally defined$academic_start_date.
function check_in_range($start_date, $end_date, $date_from_user)
{
// Convert to timestamp
$start_ts = strtotime($start_date);
$end_ts = strtotime($end_date);
$user_ts = strtotime($date_from_user);
// Check that user date is between start & end
return (($user_ts >= $start_ts) && ($user_ts <= $end_ts));
}
$academic_start_date = '20110801';
$academic_end_date = '20120731';
$startdate = '20120813';
$acyear_check = check_in_range($academic_start_date, $academic_end_date, $startdate);
if ($acyear_check == 1) { $acyear = $academic_start_date;}
else { $acyear = '';}