Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity Stream Date Format

  • @amalsh

    Participant

    Hi all,

    I want to change the activity stream date format to make it something like facebook date. I mean I need to use “… ago” date format for today’s activities and “December 31, 2012 at 10:00AM” like date format for older activities.

    How can I do this? Can this be done without modifying Buddypress core files?

    Another question, how to remove the link from the activity date?

    Thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • @chouf1

    Participant

    Hi @amalsh,

    all this can be done if you create a child theme.

    Date format is explained in the WP codex. https://codex.wordpress.org/Formatting_Date_and_Time

    And for the other question: https://buddypress.org/support/topic/how-to-remove-active-xyz-hours-ago/

     

    @amalsh

    Participant

    Thanks Chouf1 for replying… I know how to format date but where to modify it for activity in Buddypress is what I don’t know.
    Maybe I can add filter in functions.php file but what is the function that handle activity date and where is it located?

    @amalsh

    Participant

    Aha… I added this filter:
    `
    function format_activity_date() {
    $activityDate=bp_get_activity_date_recorded();
    return date(“F j, Y g:i a”, strtotime($activityDate));
    }
    add_filter(‘bp_activity_time_since’, ‘format_activity_date’);
    `

    This worked with me but still want to check if the date is today to keep the “… ago” time format, how can I do this?
    `
    function format_activity_date() {
    $activityDate=bp_get_activity_date_recorded();
    if ($activityDate>strtotime(24))
    {
    return date(“F j, Y g:i a”, strtotime($activityDate));
    }
    else
    {$activityDate;}

    }
    add_filter(‘bp_activity_time_since’, ‘format_activity_date’);
    `

    What to replace the bold code above? Mmmm

    @amalsh

    Participant

    This changes only the activity updates’ date but not the comments & replies šŸ™

    @chouf1

    Participant

    @mgkoller

    Participant

    @amalsh

    What file did you add this filter to?
    `
    function format_activity_date() {
    $activityDate=bp_get_activity_date_recorded();
    return date(ā€œF j, Y g:i aā€, strtotime($activityDate));
    }
    add_filter(ā€˜bp_activity_time_sinceā€™, ā€˜format_activity_dateā€™);
    `
    The functions.php in your theme folder? Line number? I’m looking to do something similar, Thanks in advance!

    @amalsh

    Participant

    Yes mgkoller, I added it to functions.php file of my theme. You can add it wherever you want in the file, I put it at the end of it.

    Thanks Chouf1, I’ll check the link and see if I can get something useful from it.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Activity Stream Date Format’ is closed to new replies.
Skip to toolbar