skip to Main Content

I want to create a shortcode function that returns:
2021 – 2022

And then it would update next year automatically.

This is the (broken) code I have so far:

function current_class_year(){
    return date('Y'); // current year
    return date('Y', strtotime('+1 year')); // next year
}
add_shortcode( 'current_class_year', 'current_class_year' );

Thanks for any help.

2

Answers


  1. try this

    function current_class_year(){
        return date('Y') .' - '.date('Y', strtotime('+1 year'));
    }
    add_shortcode( 'current_class_year', 'current_class_year' );
    
    Login or Signup to reply.
  2. function current_class_year(){

        return date('Y').' - '.date('Y', strtotime('+1 year')); // Will return : current year - next year
    

    }

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search