Search and replace...xxx ago. How?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • FFMG

    Search and replace...xxx ago. How?


    Hi,

    I have some cached pages and I want to display how long ago certain
    articles were written.

    But how can I display "This article was written 'yyy days' ago" when
    the whole page is cached?

    I cannot do a simple search and replace as I would need to know when
    the articles were written to compare them with the current time, (I
    have more than one article with different dates saved in the pages).

    I was thinking of tags, something like '<%article date=xxxxx>'.
    And preg_replace( "/<%article date=(xxx)>/", ('yyyy'), $data );

    But how can I use the 'xxx' to calculate the 'yyy'?

    How else would you do it?

    Many thanks

    FFMG


    --

    'webmaster forum' (http://www.httppoint.com) | 'webmaster Directory'
    (http://www.webhostshunter.com/) | 'Recreation Vehicle insurance'
    (http://www.insurance-owl.com/other/car_rec.php)
    'Free URL redirection service' (http://urlkick.com/)
    ------------------------------------------------------------------------
    FFMG's Profile: http://www.httppoint.com/member.php?userid=580
    View this thread: http://www.httppoint.com/showthread.php?t=18563

    Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

  • Michael Fesser

    #2
    Re: Search and replace...xxx ago. How?

    ..oO(FFMG)
    >I have some cached pages and I want to display how long ago certain
    >articles were written.
    >
    >But how can I display "This article was written 'yyy days' ago" when
    >the whole page is cached?
    >
    >I cannot do a simple search and replace as I would need to know when
    >the articles were written to compare them with the current time, (I
    >have more than one article with different dates saved in the pages).
    >
    >I was thinking of tags, something like '<%article date=xxxxx>'.
    >And preg_replace( "/<%article date=(xxx)>/", ('yyyy'), $data );
    >
    >But how can I use the 'xxx' to calculate the 'yyy'?
    Try preg_replace_ca llback() instead. It will receive an array of all
    matched elements in the search string. Do your calculation there and
    return the result.

    Micha

    Comment

    Working...