Created
January 30, 2014 12:47
-
-
Save messaoudi-mounir/8707661 to your computer and use it in GitHub Desktop.
Buddypress - Change activity since time like Facebook time style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---------------------------------------------------// | |
// Change activity since time like Facebook time style | |
//---------------------------------------------------// | |
add_filter('bp_activity_time_since', 'bp_activity_time_since_newformat', 10, 2); | |
function bp_activity_time_since_newformat( $time_since, &$actvitiy ) { | |
$timestamp_now = time(); | |
$timestamp_activity_date_recorded = strtotime( $actvitiy->date_recorded ); | |
if (abs($timestamp_now - $timestamp_activity_date_recorded) > 60 * 60 * 24 /* (24 hours) */) { | |
// you can change the date format to "Y-m-d H:i:s" | |
$time_since = '<span class="time-since">' . date_i18n("F j, Y H:i", strtotime( $actvitiy->date_recorded ) ) . '</span>'; | |
} | |
return $time_since; | |
} | |
add_filter('bp_activity_comment_date_recorded', 'bp_activity_comment_date_recorded_newformat', 10, 2); | |
function bp_activity_comment_date_recorded_newformat( $date_recorded ) { | |
global $activities_template; | |
$timestamp_now = time(); | |
$timestamp_comment_date_recorded = strtotime( $activities_template->activity->current_comment->date_recorded ); | |
if (abs($timestamp_now - $timestamp_comment_date_recorded) > 60 * 60 * 24 /* (24 hours) */) { | |
// you can change the date format to "Y-m-d H:i:s" | |
$date_recorded = date_i18n( "F j, Y H:i", $timestamp_comment_date_recorded ); | |
} | |
return $date_recorded; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment