Skip to:
Content
Pages
Categories
Search
Top
Bottom

How do you change the Freshness of post date format?

Viewing 19 replies - 1 through 19 (of 19 total)
  • http://uk3.php.net/manual/en/function.date.php

    Don’t have access to the code right now so not sure where in bbPress you need to edit.


    _ck_
    Participant

    @_ck_

    Remember that the date will be relative to worldwide visitors unless you list the timezone (which will be meaningless to people far outside the timezone).

    What I do on some code is list the freshness in plain english but make the title of the element the original time.

    ie.

    <span class=timetitle title="<?php echo date("r",strtotime($topic->topic_time)); ?>"><?php topic_time(); ?></span>

    Then when you mouse over the “3 days ago” it will show you the original time (in mysql format which can be changed). Then use CSS to make a light underline so the user knows it has some kind of function.

    Hi ck:

    [Remember that the date will be relative to worldwide visitors unless you list the timezone (which will be meaningless to people far outside the timezone).]

    The time isn’t of concern. I would like it to initialize to my time zone of U.S Central.

    Actually, I prefer to display the date format you have implemented in the the mouseover without implementing a mouseover rather than the current number of days format.

    What would be the code and which file is it located?

    Thank you for your response to my inquiry.

    The following code is in the front-page.php file

    <th><?php _e(‘Freshness’); ?></th>

    What file contains the code to change the Freshness of post format from the default of Days to the Date – Hours – Minutes ?


    chrishajer
    Participant

    @chrishajer

    That php _e(‘Freshness’) just echoes the table header. A couple lines beneath that you will find the call to the function that provides the time elapsed (i.e. the Freshness):

    <?php topic_time(); ?>

    Instead of that topic_time, you could just insert the code like _ck_ has shown, modified a little bit, so instead of this in your template files:

    <?php topic_time(); ?>

    use this:

    <?php echo date("date format here", strtotime($topic->topic_time)); ?>

    where date format here is some combination of characters from here: http://www.php.net/date

    For example:

    <?php echo date("D M j Y G:i:s", strtotime($topic->topic_time)); ?>

    prints like Sun Aug 19 2007 1:53:54 right now, but it would be based on the topic time of the post in your case.

    You would need to look at these files, at least, in your template directory:

    ./favorites.php

    ./forum.php

    ./front-page.php

    ./tag-single.php

    ./view.php

    It’s safe to modify your own template files. You’re not modifying the core bbPress files. But maybe this would be better as a plugin, I’m not sure.

    Good luck.

    Hi chrishajer:

    I moved the files you listed to my-templates folder then edited using the code

    <?php echo date(“D M j Y G:i:s”, strtotime($topic->topic_time)); ?>

    I FTPed the files to my server.

    The new date time format appears to be working.

    Thanks.


    Sam Bauers
    Participant

    @sambauers

    I believe you can do this…

    <?php topic_time('D M j Y G:i:s'); ?>

    But I’ve never tried it.

    bump

    Sam’s code works but still it displays the time in GMT rather than in my timezone. That doesn’t seem right cause it display the proper time since. How do I get that correctly?

    (same thing with _ck_’s code – off the time zone and into GMT)

    EDIT:

    looking through some bbPress code I think I’ve got it right at last! The time has to be filtered through bb_offset_time, so the code should be(for post times):

    echo date("date-format-goes-here", bb_offset_time(strtotime($bb_post->post_time)));

    Still wonder why isn’t the time filtered when using sam’s code…

    EDIT again:

    and it does not localize – the date is in English… wonder how to set that up?


    piedpiper21
    Member

    @piedpiper21

    I like ck’s method of displaying the dates and I tried applying her code to the front-page.php file. But when I change the code under ‘$super_stickies’ and ‘$topics’ from

    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php topic_time(); ?></a></td>

    to

    <td class="num"><a href="<?php topic_last_post_link(); ?>"><span class=timetitle title="<?php echo date("r",strtotime($topic->topic_time)); ?>"><?php topic_time(); ?></span></a></td>

    There is no change.

    If I change it to

    <td class="num"><a href="<?php topic_last_post_link(); ?>"><?php echo date("r",strtotime($topic->topic_time)); ?>"></a></td>

    I get a properly formatted time description. But I can’t get the title to work. What am i doing wrong?


    piedpiper21
    Member

    @piedpiper21

    Bump


    _ck_
    Participant

    @_ck_

    You don’t have title anywhere in there.

    And I don’t understand what you are trying to do.

    Do you want the regular text to read the “days ago” part or the title to hold it?


    piedpiper21
    Member

    @piedpiper21

    <td class="num"><a href="<?php topic_last_post_link(); ?>"><span class=timetitle title="<?php echo date("r",strtotime($topic->topic_time)); ?>"><?php topic_time(); ?></span></a></td>

    I was referring to the title in this line.

    And I’m trying to implement the code you gave above.

    I want the regular text to read the freshness and the title to hold the exact date.


    _ck_
    Participant

    @_ck_

    Based on what you showed me that is working, mine should work fine.

    Here is a simplified version:

    <td class="num"><a href="<?php topic_last_post_link(); ?>"  title="<?php echo date("r",strtotime($topic->topic_time)); ?>"><?php topic_time(); ?></a></td>

    I think the problem with the old example is I used a php shortcode (<?) instead of the full <?php and some servers have a problem with it, maybe yours. I’ve now edited all examples on this page to use the full <?php to prevent confusion by future viewers.


    piedpiper21
    Member

    @piedpiper21

    I don’t think it’s a problem using <? as I was able to change it to a timestamp format with that.

    I tried the simplified code, still the same problem. Only the regular freshness, no title.


    _ck_
    Participant

    @_ck_

    Just to be certain, you understand how titles work right? You mouse over it to see it.

    Maybe try doing a “view source” to make sure it’s there.

    You’ve already proved that the code will output the date, all we’ve done is just move it into the hidden, mouse-over title.

    Show me the view source part just for what it outputs.


    piedpiper21
    Member

    @piedpiper21

    Great, I misunderstood how it works. When you said mouse over, I thought the text should change to show the date. Sorry, for the misunderstanding. Thanks again.


    bedbugger
    Participant

    @bedbugger

    Thanks for this, _ck_, dragunoff and all!

    I installed _ck_’s Forum Last Poster plugin to show FRESHNESS for my forums, but I am trying to convert it to the exact time/date.

    I have tried various permutations with no luck.

    The following code doesn’t work:

    <td class=”num”><?php forum_time(“D M j, Y”); ?></td>

    The following code just gives a static date of Wed Dec 31, 1969:

    <td class=”num”><?php echo date(“D M j, Y”, bb_offset_time(strtotime($bb_forum->forum_time))); ?></td>

    Any ideas how I can do this?

    Thanks.

    To expand a bit on my above post…

    1. This gives me the correct time in topic.php: <?php topic_time(“D M j, Y g:i a”); ?>

    2. This gives me the wrong time (+4hrs) in post.php: <?php echo date(“D M j, Y g:i a”, (strtotime($bb_post->post_time))); ?>

    3. This gives me a static date of Wed Dec 31, 1969 in front page.php: <td class=”num”><?php echo date(“D M j, Y”, bb_offset_time(strtotime($bb_forum->forum_time))); ?></td>

    If anybody knows how I can correct the final two, I would be grateful.

    Thanks.

Viewing 19 replies - 1 through 19 (of 19 total)
  • You must be logged in to reply to this topic.
Skip to toolbar