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

  • Home
  • SEARCH
  • 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 7824133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:29:41+00:00 2026-06-02T08:29:41+00:00

How do i get 3 months after the date of today in php? From

  • 0

How do i get 3 months after the date of today in php?

From PHP i’ll get todays date by date("Y-m-d"); lets say 2012-02-22

How i’ll get a date after 3 months…. i.e 2012-05-22

EDIT:-

The issue is about different number of days in different months, feb have 28 days also and 29 in leap… odd months 31 and others 30… Is there any pre-built function in php which i can use to deal with this issue… ??

EDIT 2

With all responses i understood that it would be a problem:-

In reference to https://stackoverflow.com/a/10275921/1182021 [+1]

So i think it would be better of writing a manual function for it… and i’ll put it here as an answer… Thanks for everyone help and support..

ANSWER TO THIS QUESTION

We need to check all the conditions manually for accurate calculations… there is no inbuilt function for this in PHP…. https://stackoverflow.com/a/10280441/1182021

  • 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-02T08:29:43+00:00Added an answer on June 2, 2026 at 8:29 am

    This is a 100% working code to accomplish the task

    <?php
    $month = date('n');
    $year = date('Y');
    $IsLeapYear = date('L');
    $NextYear = $year + 1;
    $IsNextYearLeap = date('L', mktime(0, 0, 0, 1, 1, $NextYear));
    $TodaysDate = date('j');
    if (strlen($month+3) < 10)
    {
        $UpdateMonth = "0".($month+3);
    }
    if ($month > 9) {
        if ($month == 10)
        {
            $UpdateMonth = "01";
        }
        else if ($month == 11)
        {
            $UpdateMonth = "02";
        }
        else
        {
            $UpdateMonth = "03";
        }
    }
    
    if (($month != 10) && ($month != 11) && ($month != 12))
    {
        if(($month&1) && ($TodaysDate != 31))
        {
            $DateAfterThreeMonths = $year."-".$UpdateMonth."-".$TodaysDate;
        }
        else if (($month&1) && ($TodaysDate == 31))
        {
            $DateAfterThreeMonths = $year."-".$UpdateMonth."-30";
        } 
        else {
            $DateAfterThreeMonths = $year."-".$UpdateMonth."-".$TodaysDate;
        }
    }
    else if ($month == 11)
    {
        if (($TodaysDate == 28) || ($TodaysDate == 29) || ($TodaysDate == 30))
        {
            if ($IsLeapYear == 1)
            {
                $DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-28";
            }
            else if ($IsNextYearLeap == 1)
            {
                $DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-29";
            }
            else
            {
                $DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-28";
            }
        }
        else
        {
            $DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-".$TodaysDate;
        }
    }
    else
    {
        $DateAfterThreeMonths = ($year+1)."-".$UpdateMonth."-".$TodaysDate;
    }
    echo $DateAfterThreeMonths; 
    ?>
    

    We can check the stuff manually by using this piece of code in top:-

    // Just change the values of $month, $year, $TodaysDate
    $month = 11;
    $year = 2012;
    $IsLeapYear = date('L');
    $NextYear = $year + 1;
    $IsNextYearLeap = date('L', mktime(0, 0, 0, 1, 1, $NextYear));
    $TodaysDate = 31;
    

    Just copy and paste the code, check it in your browser 🙂

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

Sidebar

Related Questions

About 5 times over the past 6 months, in complex javascripts, I'll get an
after several months having the site disappear from search results in every major search
How can I subtract a length-of-time from a boost gregorian date? Let's say I
Today is Tuesday, February 9, 2010 and when I print the date I get
i want to send an auto mail after every 6 months from the registration
Is there any way to get the # of months and years since a
Possible Duplicate: What are C macros useful for? Every few months I get an
The last months I have tried to get started with web developing using Java.
Is there an easy way to get the number of months(over multiple years) that
I need to get the last day of the month given as a date

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.