[Resolved] Activity ‘Posted an update’ – Displaying time but wrong timezone?
-
Hi all,
Found a couple of useful code snippets to change the ’15 minutes ago’, ‘1 day ago’ etc into actual times and dates on the activity stream. Might be useful so thought I’d post:
https://gist.github.com/dzmounir/8706592
(courtesy of dzmounir)add_filter('bp_activity_time_since', 'bp_activity_time_since_newformat', 10, 2); function bp_activity_time_since_newformat( $time_since, &$actvitiy ) { // you can change the date format to "Y-m-d H:i:s" $time_since = '<span class="time-since">' . date_i18n("F j, Y", 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; // you can change the date format to "Y-m-d H:i:s" $date_recorded = date_i18n("F j, Y", strtotime( $activities_template->activity->current_comment->date_recorded ); return $date_recorded; }
There is the issue of the time being incorrect however (in my case, out by 1 hour). If i choose a city under WP Dash>Settings General>Timezone, the code found in the old forum post below can be used/integrated to correct the issue. But if the timezone is set to a UTC value, it doesn’t work.
This old forum post discusses issue of incorrect post time:
https://buddypress.org/support/topic/activity-time-is-gmt-activity-stream-posted-an-update-time-is-incorrect/So my questions are:
1. Is there a way to always display the local user’s post time (even if they are international)
2. What timezone setting should be applied in the back end on WP Dash in order to address this issue of incorrect post time (or is using the code above and specifying a city the only way)?
2. If i specify a city which fixes the issue for me personally, does that mean another international site user would have wrong post times appear on their activity streams when they use it their end?
Thanks
WP : 4.2.2
BP : 2.2.3.1
- The topic ‘[Resolved] Activity ‘Posted an update’ – Displaying time but wrong timezone?’ is closed to new replies.