How do I echo the financial year?

Try this:

if (date('m') <= 6) {//Upto June 2014-2015
    $financial_year = (date('Y')-1) . '-' . date('Y');
} else {//After June 2015-2016
    $financial_year = date('Y') . '-' . (date('Y') + 1);
}

try something like:

if ( date('m') > 6 ) {
    $year = date('Y') + 1;
}
else {
    $year = date('Y');
}

Short hand notation:

$year = ( date('m') > 6) ? date('Y') + 1 : date('Y');

That should be simple enough, something like:

if (date('m') <= 6) {
    $year = date('Y');
} else {
    $year = date('Y') + 1;
}

Alternatively, you could use an single expression that maps the month to a zero/one value depending on whether it's in the first or second half of the calendar year, then adds that to your calendar year:

$year = date('Y') + (int)((date('m') - 1) / 6);

Its too Simple

if (date('m') >= 6) {
    $year = date('Y') + 1;
} else {
    $year = date('Y');
}

try this one!

Tags:

Php

Date

Calendar