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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:15:14+00:00 2026-06-17T16:15:14+00:00

I am building a search script that will filter results based on ages: Posts

  • 0

I am building a search script that will filter results based on ages:

  • Posts are people on my site.
  • The age is entered as a date of birth in a custom field.

I am confident I can write a function to convert this date of birth to an age, then add it again as another custom field.

My only worry is, what happens each year when they get older? I am not too sure what to do. I could have a script that runs each day…but this feels like a cheat.

  • 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-17T16:15:15+00:00Added an answer on June 17, 2026 at 4:15 pm

    I’ve got a site where there is:

    echo "If Joe was alive, he would be" . get_age( "1948-06-18" ) . "years old";

    And in the theme’s functions.php this:

    // Calculate the age from a given birth date
    // Example: get_age("YEAR-MONTH-DAY");
    function get_age( $birth_date )
    {
        // Explode the date into meaningful variables
        list( $year, $month, $day) = explode( "-", $birth_date );
    
        // Find the differences
        $y_diff = date( "Y" ) - $year;
        $m_diff = date( "m" ) - $month;
        $d_diff = date( "d" ) - $day;
    
        // If the day has not occured this year
        if ( $d_diff < 0 || $m_diff < 0 )
          $y_diff --;
    
        return $y_diff;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a simple search feature using jQuery that will filter a list of
I am building a php script to search and scrape google pages that uses
I am building a comics/artwork website that will let you search for material. The
I've been building this site that will get run an API depending on the
I'm building a real-estate site where my visitors need to search based on ranges.
i am building a search index that contains special names - containing ! and
If I'm building a commercial search engine to display results from Yahoo! search, should
I am working on building my first search-engine friendly CMS. I know that perhaps
I'm building a search on my site and I noticed it doesn't work when
I've got a database site that will serve approximately 1,200 primary entries at launch,

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.