Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hello from Japan! How to display day of the week …


  • yoosuke
    Participant

    @yoosuke

    I’m looking for advice on how to display day of the week at “reply-post-date”.

    In topic pages, “at” is used in the display of posting date. like…

    2014/05/28 at(←here!) 00:21

    I want to replace the display from “at” to “(Sun)”.
    In other words, I want to display a day of the week of posting time.

    I tried many times by using PHP function “preg_replace”.
    However, it was too difficult for me. Code that I made ​​is as bellow.

    function change_reply_post_date($output) {
    $output = preg_replace( '/at/' , "<?php echo get_post_time('D'); ?>" , $output );
    return $output;
    }
    add_filter( 'bbp_get_reply_post_date' , 'change_reply_post_date');

    In this case, it did not result in an error.
    However, “at” disappeared.

    What should I do?
    Would you please advice me?

    WordPress: ver3.9.1
    bbPress: ver2.5.3

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

  • Robin W
    Moderator

    @robin-w

    You were very close !

    function change_reply_post_date($output) {
    $day= '('.get_post_time('D').')';
    $output = preg_replace( '/at/' , $day , $output );
    return $output;
    }
    add_filter( 'bbp_get_reply_post_date' , 'change_reply_post_date');
    

    the line $day…etc. sets $day equal to an ‘open bracket’, followed by the day, followed by a ‘close bracket’ – the full stops are a concatenate in php.

    your original "<?php echo get_post_time('D'); ?>" does the following
    <?php = switch on php – we’re already in php, so not needed
    echo = send to screen – but we don’t want that, we want the result to be sent, which will be done by other code
    get_post_time= that’s the key part that you had figured
    ?> = ends php, which we don’t want to do as the rest of the line is php


    yoosuke
    Participant

    @yoosuke

    Hi! Mr Robin W!

    Now, my Website is likely to complete.
    Thanks to you. (Detailed description of PHP codes was very helpful for me!)

    My Website is a site to help people.
    Near future, some troubles might be found in my Website.(It might be tomorrow..orz)

    At that time,
    I would be happy if you come back and advice me.

    Best regards.


    Robin W
    Moderator

    @robin-w

    great, glad you are fixed !!

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