Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to Display the Post Time in Forums


  • bpisimone
    Participant

    @bpisimone

    How can I display the time of the post in the forum?

    E.g. If I wanted to display todays date like this:

    25 OCT

    In bbpress I used this

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

    But it does not work anymore in the BP/Bbpress installation. So how do you display the date in that fashion?

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

  • bpisimone
    Participant

    @bpisimone

    Anyone feel like helping today? Pretty please?


    Boris
    Participant

    @travel-junkie

    Hey,

    actually, the j should only give you the day of the month and nothing more. If you want the day and the month you need to use “j M”.

    The rest should work just as you wrote it if you have access to the variable $topic. Try this:

    var_dump( $topic );

    and see what it outputs. If there’s nothing or NULL, then you’ll have to populate $topic first.


    bpisimone
    Participant

    @bpisimone

    Thanks there Travel-Junkie

    How exactly would I populate $topic?

    It’s not that

    <?php echo date("j", strtotime($topic->topic_time)); ?>
    <?php echo date("M", var_dump($topic->topic_time)); ?>

    isn’t working entirely, it just gives me completely wrong numbers (1 JAN). And if I’ve done the var_dump right it indeed gives me a NULL.

    Thanks again :)


    Boris
    Participant

    @travel-junkie

    You need to put the var_dump stuff on its own line below your original date function :)

    Just had a look at the forum functions and here’s what you need to do.

    global $forum_template;
    echo date("j", strtotime($forum_template->topic->topic_time));

    Let me know if it doesn’t work.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to Display the Post Time in Forums’ is closed to new replies.
Skip to toolbar