Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show exact date of post? (not freshness)


  • maker
    Member

    @maker

    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)

Viewing 22 replies - 1 through 22 (of 22 total)

  • fel64
    Member

    @fel64

    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.


    maker
    Member

    @maker

    Thanks fel64,

    So I paste that in post.php?

    around this stuff?

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


    fel64
    Member

    @fel64

    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. :)

    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

    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. :)

    I have a problem with this displaying the incorrect date. Do I need to set anything to get the correct date?

    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.

    It shows “Thu, 01 Jan 1970″ for every post.

    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; ?>

    Sorry, but no change.

    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;
    }
    ?>

    Thank you fel64!

    I owe you a wealth of sundays!

    So many unarchived plugins that are so nice…


    _ck_
    Participant

    @_ck_

    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


    schmitt
    Member

    @schmitt

    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.


    itissue
    Member

    @itissue

    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?

    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

    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.


    blah
    Member

    @crackpixels

    I used fel’s plugin and I’m getting December 31, 1969 for every post. How can I fix this?


    iftomkins
    Participant

    @iftomkins

    Thanks @fel64! Even a few years later it’s still fresh and delicious–works like a dream.


    hanachristina
    Member

    @hanachristina

    I use Accurate Post Time plugin, to changing the date format. It’s so easy.

    Sorry for my very poor english

    I can’t believe that in bbpress forum there is no such a fundamental thing as post and topic date! I thing 80% of forum users need exact post date, not its freshness.

    I spend a lot of time on this issue and finally fixed it!

    All you need is to use both “Accurate Post Time” AND “User Timezones” plugins. First is for showing date and second is for setting it correctly.

    It works fine for me!

Viewing 22 replies - 1 through 22 (of 22 total)

You must be logged in to reply to this topic.