Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Activity ‘Posted an update’ – Displaying time but wrong timezone?

@almase

Participant

i now have these codes in my function.php:


function bp_activity_comment_date_recorded_newformat( $date_recorded ) {
	global $activities_template;
	$root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' );
    $time_offset = $time + ( $root_blog_offset * 3600 );

	$timestamp_now = time();
	$timestamp_comment_date_recorded = strtotime( $activities_template->activity->current_comment->date_recorded );

	if (abs($timestamp_now - $timestamp_comment_date_recorded) > 0 * 0 * 0 /* (24 hours) */) {
		// you can change the date format to "l, j. F Y - H:i:s"
		$date_recorded = date_i18n( "l, j. F Y - H:i:s", $timestamp_comment_date_recorded );
	}
	return $date_recorded;

}
add_filter('bp_activity_comment_date_recorded', 'bp_activity_comment_date_recorded_newformat', 10, 2);

function format_activity_date() {
  $activityDate=bp_get_activity_date_recorded();
  // Get GMT offset from root blog
  $root_blog_offset = get_blog_option( BP_ROOT_BLOG, 'gmt_offset' );
  // Calculate offset time
  $time_offset = $time + ( $root_blog_offset * 3600 );
  // Format the time using the offset and return it; date-i18n retrieves the date in localized format
  return '' . date_i18n("l, j. F Y - H:i:s", strtotime($activityDate) + $time_offset) . '';
}
add_filter('bp_activity_time_since', 'format_activity_date');

The first posting in stream has now the right timezone, but not the comments… 🙁

Skip to toolbar