Skip to:
Content
Pages
Categories
Search
Top
Bottom

Making Activity Time just like FB time


  • Hope
    Participant

    @amalsh

    Hi dears,

    I want to make the BP Activity Stream time just like FB time. i.e. I want the “..ago” format for today only but a specific date “December 25, 2013” for the rest.
    Anybody knows how to do this?

    I wrote a small function:

    function format_activity_timestamp() {
      $activityDate=bp_get_activity_date_recorded();
      if ($activityDate != DateTime())
      {
          return date("F j, Y g:i a", strtotime($activityDate));
      }
      else
      {$activityDate;}
    
    }
    add_filter('bp_activity_time_since', 'format_activity_timestamp');

    but don’t know what to replace the condition! I mean if it’s not today’s date, make it a specific date format otherwise keep the “..ago” format.

    Any help will be appreciated.

    Thanks
    Hope

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

  • meg@info
    Participant

    @megainfo

    Hi @amalsh,

    Use this code, it’s should work!

    https://gist.github.com/dzmounir/8706592


    Hope
    Participant

    @amalsh

    Hi @megainfo,

    Thanks for your quick reply & for the code! Actually I want to keep today’s format as “..ago” and change every date before today to the exact data+time.

    Your code changes the whole activity time to the exact data+time. What can be done to keep the time_since for today’s activities only?

    Thanks
    Hope


    meg@info
    Participant

    @megainfo

    Ok, i think i understand now,

    please check this code:


    https://gist.github.com/dzmounir/8707661

    I add a test ( if activity date > 24h, the code will show the new format date).


    Hope
    Participant

    @amalsh

    Hi @megainfo,

    Thanks a lot for the code, it works great for the activity comments while it doesn’t for the activity updates although it makes sense! I’m checking where the problem could be.

    Thanks a lot for your help!
    Hope


    Hope
    Participant

    @amalsh

    The strange thing is that all activity dates appears as “exact date time” after loading for half a second then it all turns to “…ago” format! Mmmm…


    bkypes
    Participant

    @bkypes

    Quick question, what file should I add this code to, or what folder should I create a new file for this code in?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Making Activity Time just like FB time’ is closed to new replies.
Skip to toolbar