How to Calculate the Percentage through the Tax Year in PHP

development 4

Recently a client requested that we display for them a percentage of how far through the tax year we are. I did some looking online however I couldn’t find anything which suited my needs.

Below is the code I ended up writing which will calculate the percentage value and display the output at the end.

$currentMonth     = date(‘n’);

$currentYear      = date(‘Y’);

$dayInYear        = date(‘z’);


$taxYearStartYear = $currentMonth < 4 ? $currentYear – 1 : $currentYear;

$taxYearStart     = $taxYearStartYear . ‘-04-01 00:00:00’;

$taxYearStartDay  = date(‘z’, strtotime($taxYearStart));


$taxDayInYear     = $dayInYear < $taxYearStartDay ? ($dayInYear + 365) – $taxYearStartDay : $dayInYear – $taxYearStartDay;


$taxYearPassed    = ($taxDayInYear / 365) * 100;


echo $taxYearPassed.’% of the way through the tax year’;


DSM Design LTD - Brand Logo

Contact DSM Design

Contact DSM Design for your development and technical solutions today. Either enquire online through our form or call us on 01202 048079.

Contact Us

Latest News

View All Articles