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 6543317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:19:55+00:00 2026-05-25T11:19:55+00:00

I managed to do this on excel by using the following (note that I

  • 0

I managed to do this on excel by using the following (note that I use the dd/mm/yyyy date format:)

User inputs Date assigned to cell A101/01/2007

Calculation to find out current tax year =IF(MONTH(A1)<>4,YEAR(A1)-1,IF(DAY(A1)>=6,YEAR(A1),YEAR(A1)-1)) Result is the current tax year is year 2006

That Date’s Tax year begins = =DATE(A1,4,6) result of 06/04/2006

Day before the Tax year ends = =DATE(R54+1,4,5) result of 05/04/2007

Max number of days =ABS((R55-R56))+1 result = 365 (used to detect leap years)

Number of days passed in the tax year =ABS(R53-R55-R57) result = 95

Works out percentage of tax year left =(R58/R57)*100 result is 26.02739726

Now i need to do the same in PHP, and honestly have no idea where to start.

  • 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-05-25T11:19:56+00:00Added an answer on May 25, 2026 at 11:19 am

    I would use PHP’s DateTime class and the DateTime::diff method:

    <?php
    $tz = new DateTimeZone("UTC"); // Set to one of the supported time zones: http://www.php.net/manual/en/timezones.php
    $tax_year_begin_dt = new DateTime("2006-04-06", $tz);
    $tax_year_end_dt = new DateTime("2007-04-06", $tz);
    $num_days_in_tax_year = $tax_year_begin_dt->diff($tax_year_end_dt)->days;
    echo "\$num_days_in_tax_year = $num_days_in_tax_year<br>\n";
    $dt = new DateTime("2007-01-01", $tz);
    $num_days_remaining = $dt->diff($tax_year_end_dt)->days;
    echo "\$num_days_remaining = $num_days_remaining<br>\n";
    $percent_remaining = 100.0*$num_days_remaining/$num_days_in_tax_year;
    echo "$percent_remaining%<br>\n";
    

    The output of this code is:

    $num_days_in_tax_year = 365
    $num_days_remaining = 95
    26.027397260274%
    

    http://codepad.viper-7.com/WNxRHS

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I managed to get authentication to work by following the tutorial from this page
I have this line in a useful Bash script that I haven't managed to
Have you managed to get Aptana Studio debugging to work? I tried following this,
I have a managed dll that calls into a native library. This native library
This is purely an Excel sheet question. I have a time span that is
I've got an Excel workbook that's got some crazy calculations in it. I managed
After cobbling together a few questions I've managed to get this far to showing
I cannot seem to compile mod_dontdothat on Windows. Has anybody managed to achieve this?
I need this roadmap of a Hibernate managed object instance. First, I create an
I've managed to mostly ignore all this multi-byte character stuff, but now I need

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.