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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:58:05+00:00 2026-06-03T12:58:05+00:00

In a new project, I’m working with rss being read by PHP and displayed

  • 0

In a new project, I’m working with rss being read by PHP and displayed on a page.
One thing I’d like to do is show how much time has passed since the post was published, but I can’t find a way to do so, this is my current code, hope somebody can help me!

echo "<div id=\"left\">";
    $rss1 = new DOMDocument();
    $rss1->load('http://www.macfan.nl/macfan.rss');
    echo '<h2>MacFan</h2>';
    $feed = array();
    foreach ($rss1->getElementsByTagName('item') as $node) {
        $item = array ( 
            'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
            'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
            'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
            );
        array_push($feed, $item);
    }
    $limit = 5;
    for($x=0;$x<$limit;$x++) {
        $title = str_replace(' & ', ' &amp; ', $feed[$x]['title']);
        $link = $feed[$x]['link'];
        $date = date('F d', strtotime($feed[$x]['date']));
        echo '<p><a href="'.$link.'" title="'.$title.'">'.$title.'</a></p>';
        echo "<p class=\"small\">$date</p>";
    }
echo "</div>";
  • 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-03T12:58:09+00:00Added an answer on June 3, 2026 at 12:58 pm

    You can compare the unix timestamps;

    $seconds_between_now_and_then=(time()-strtotime($feed[$x]['date']));
    

    Then you can see how far it is apart. These below could help you make it more readable for yourself:

    $minutes_between_now_and_then=$seconds_between_now_and_then/60;
    $hours_between_now_and_then=$minutes_between_now_and_then/60;
    $days_between_now_and_then=$minutes_between_now_and_then/24;
    
    echo 'Seconds:'.$seconds_between_now_and_then.'<br />';
    echo 'Minutes:'.$minutes_between_now_and_then.'<br />';
    echo 'Hours:'.$hours_between_now_and_then.'<br />';
    echo 'Days:'.$days_between_now_and_then;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need :project_owners to invite new :project_participants to a project. Much like in Basecamp,
Starting a new project and would like to use one of the MVC framworks.
I working on a new project and I have to develop an inverted index
For a new project that I'm doing in PHP I've created an SQLMethods class
While recently imported a new project into eclipse, at one point when I tried
I'm starting one new project, and I need to choose the best technology to
I have a new project where I am using GWT-Views like Composite, etc. I
I'm starting a new project divided into two parts: a php application and a
Starting a new project I'd like to use Hibernate annotations with MySQL instead of
Working on a new project I've run into a major roadblock that has brought

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.