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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:11:20+00:00 2026-06-15T02:11:20+00:00

I have dates stored in array for completion status of projects like below The

  • 0

I have dates stored in array for completion status of projects like below

The first two letters are months and other four letters are years

052012(mmyyyy)

$arrDates = array('052012', '042013', '082013', '122013', '022014');

I want this array To get converted to wordings as below

$arrDates = array('Completed', 'Next Six Months', 'Next Year', 'Next Year', 'After 2 Years');

I used a for loop like below for checking completed as below

for($i=0;$i<count($arrDates);$i++)
{
  if((date('m') > substr($arrDates[$i], 0,2)) && (date('y') == substr($arrDates[$i], 2,6)))           
  $strStatus = ' Completed';
}

and I messed up in finding for next year and other two.

Could some one help me in fixing this?

  • 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-15T02:11:21+00:00Added an answer on June 15, 2026 at 2:11 am

    I think you can use DateTime and dateInterval for this :

    $currentDate = DateTime::createFromFormat('mY',$arrDates[0]);
    $interval = $currentDate->diff(new DateTime('now'),true);
    if($interval->invert){
       echo 'Completed';
    else if($interval->y >= 2 ){
       echo 'After 2 Years';
    }
    else if($interval->y == 1){
       echo 'Next Year';
    }
    else if($interval->m > 6){
       echo 'what you want here';
    }
    else {
       echo 'Next six months';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two drop-down lists populated from an array of same dates stored in
I have a Date array which stored dates and time in its respective positions
I have retrieved few dates from an array ,which where stored in string format
I have an array of dates in a one week range stored in an
I have a multi dimensional array, like this: array('name' => array('title'=>'Title','date'=>'Created')) I store it
I have dates stored in MongoDB using Date(), MongoDB uses UTC it's date type,
I have all dates stored as timestamps (int) in the database. how can I
In my SQL Server database I have the dates stored as char(12) in the
I have dates in SQL stored as DateTime, when showing them in a textbox
I have a list of dates stored in MySQL using PHP. These were stored

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.