Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8384695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:28:15+00:00 2026-06-09T17:28:15+00:00

I am trying to write a script that would work out the current academic

  • 0

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 = '';}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T17:28:17+00:00Added an answer on June 9, 2026 at 5:28 pm
    $time = ??;// here you put timestamp, it also may be strtotime(smth);
    
    $year = date('Y', $time);
    if(date('n', $time) < 8)
         $ayear = ($year - 1).'/'.$year;
    else
        $ayear = ($year).'/'.($year + 1);
    

    For your format:

    $datestr = 'YYYYmmdd';
    $year = substr($datestr, 0, 4);
    if(intval(substr($datestr,4,2)) < 8)
         $ayear = ($year - 1).'/'.$year;
    else
        $ayear = ($year).'/'.($year + 1);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a Perl script that will work better with KDE's kwrited
I am trying to write an awk script that can get a block that
I'm trying to write a script that will create a user in MediaWiki, so
I'm trying to write a script that allows an admin of a photo uploading
I'm trying to write a script that will download files from an FTP server.
I'm trying to write a script that searches a directory for files and greps
I'm trying to write a script that adds the left side of a string
I'm currently trying to write a script that will connect to a site using
THANKS FOR HELPING!!! Ok... So I am trying to write a script that will
I'm trying to write a Python script that uses a particular external application belonging

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.