bbPress

Simple, Fast, Elegant

bbPress support forums » Troubleshooting

Show exact date of post? (not freshness)

(19 posts)
  • Started 1 year ago by maker
  • Latest reply from fel64
  • This topic is not resolved
  1. I like the 'freshness' and all but how do I show the exact date of a post? Preferably at the bottom of the actual post (where currently a repeat of the freshness is)

    Posted 1 year ago #
  2. I suspect that this will work. Replace get_post_time() or whatever it is with

    global $post;
    echo $post->post_time;

    (Remember to have the <?php ... ?> tags around it!) If you want different formatting on that, I think that $post->post_time is a bit too much detail so you could instead have

    global $post;
    $lalaposttime = date( 'D M Y', strtotime( $post->post_id ) );
    echo $lalaposttime;

    You can change the way the date will appear by changing the first parameter (currently it's 'D M Y') of the date() function. A list of how you can format dates is here.

    Posted 1 year ago #
  3. Thanks fel64,

    So I paste that in post.php?

    around this stuff?

    <?php printf( __('Posted %s ago'), bb_get_post_time() ); ?>

    Posted 1 year ago #
  4. Paste in

    <?php global $post;
    $lalaposttime = date( 'D M Y', strtotime( $post->post_id ) );
    echo $lalaposttime; ?>

    anywhere you like outside other <?php ... ?> tags. So you could put it next to the code snippet you quoted. If you use Notepad 2 or something it makes it a lot easier by colour-coding these things.

    The fact that it's spread out over several lines doesn't make a difference when it's inside the <?php ... ?> tags. :)

    Posted 1 year ago #
  5. Hi Fel64,

    Thanks for your help.

    I get "THU JAN 1970" now. (I'd prefer the exact date)

    Like here: http://www.mpm.org.au/topic/7?replies=1

    Posted 1 year ago #
  6. Replace D M Y with a date-formatted string of your choice. It's quite an interesting but simple system. Each letter stands for a different type of date or time. So D is replaced by first three letters of the weekdate, M by first three of the month etc.

    This reference will tell you what letters to use to see what date outputs you get. Roll your own date format. :)

    Posted 1 year ago #
  7. I have a problem with this displaying the incorrect date. Do I need to set anything to get the correct date?

    Posted 1 year ago #
  8. What does it show? Something completely crazy or something slightly wrong?

    You can set your timezone in config.php, just change $bb->gmt_offset to whatever you want.

    Posted 1 year ago #
  9. It shows "Thu, 01 Jan 1970" for every post.

    Posted 1 year ago #
  10. I see. Sorry, I thought that was just an example for the format.
    How's this instead?

    <?php global $post;
    $lalaposttime = date( 'D M Y', strtotime( $post->post_time ) );
    echo $lalaposttime; ?>
    Posted 1 year ago #
  11. Sorry, but no change.

    Posted 1 year ago #
  12. Okay, I promise in future I'll be all mature and responsible and test these things first. Sorry for the inconvenience. This works on my forum now; just copy and paste this into a new plugin file. Then put <?php aposttime(); ?> for default time output, or <?php aposttime( 'DATE FORMAT' ); ?> for your own time formatting.

    <?php
    /*
    Plugin Name: Accurate Post Time
    Plugin URI:
    Description: Outputs an accurate post time in, optionally, your choice of formatting. Use <?php aposttime( 'DATE FORMAT' ); ?> in your template, <a href="http://uk3.php.net/date">date formatted according to PHP standards.</a>
    Author: fel64
    Version: Phi
    Author URI: http://www.loinhead.net/
    */
    
    function aposttime ( $dtformat = "jS F 'y" ) {
    	global $bb_post;
    	$aposttime = date( $dtformat, strtotime( $bb_post->post_time ) );
    	echo $aposttime;
    }
    ?>
    Posted 1 year ago #
  13. Thank you fel64!

    I owe you a wealth of sundays!

    Posted 1 year ago #
  14. So many unarchived plugins that are so nice...

    Posted 10 months ago #
  15. See my post in this thread for a similar way to handle this by allowing both freshness and exact time in a title attribute:

    http://bbpress.org/forums/topic/how-do-you-change-the-freshness-of-post-date-format

    Posted 10 months ago #
  16. I can't seem to get this to use the time offset in config.php. It displays the post time in GMT, all the time. I have this in my config.php.

    $bb->gmt_offset = -5;

    Changing the value has no effect on the displayed time.

    Posted 9 months ago #
  17. itissue
    Member

    I tried changing the date format using fel64's wonderful plugin. It works great except the time is inaccurate. I have the timezone displayed. It shows the eastern time zone apparently. The problem is, the time displayed is obviously off by a lot. It says I posted something at 3:22 PM EST when in reality I posted it at 9:30 AM central time, which is 10:30 AM eastern time. Does anyone have an explanation for this? To see what I mean, go to http://tapestry.endless-sonata.net . Hover over the freshness to see the exact time.

    Edit: The timezone is supposed to be GMT, but apparently it's displayed as EST. Strange. Is there a way to display the time zone selected by the user or hardcoded on config.php?

    Posted 9 months ago #
  18. csseur3
    Member

    Hi fel64, how to adapt your plugin for integrate the ck's plugin "forum last poster": http://bbpress.org/plugins/topic/123 and show the exact date with the two plugins?

    thanks

    Posted 3 months ago #
  19. Hack her plugin to use a custom time-displaying function instead of the bbPress ones. I've set up a ticket asking for it to be simple to do what you want but I don't believe it's that easy right now.

    Posted 3 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.