Skip to content

Conversation

@rollybueno
Copy link

This PR fixes an issue where BuddyPress would display incorrect "time since" values (such as "registered sometime ago") for users in non-UTC timezones. The root cause was a mismatch between the timezone of stored registration/activity dates (site local time) and the "current time" used for comparison (UTC), leading to negative or inaccurate results.

Changes

  • Updates bp_core_time_diff() to use the site’s timezone (via wp_timezone(), available since WP 5.3) when parsing MySQL datetime strings.
  • Falls back to the previous UTC-based logic for older WordPress versions.
  • Ensures both dates are compared in the same timezone, fixing the calculation for all users regardless of site timezone.

Fixes: https://buddypress.trac.wordpress.org/ticket/9284

);
// Use site timezone if available (WP 5.3+), fallback to UTC.
if ( function_exists( 'wp_timezone' ) ) {
$dt = date_create( $r[ $date ], wp_timezone() );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In what ways does date_create() fail here? I see that you're checking for success on the next line. If it fails, would falling back to the legacy time parser work? It depends on what makes it fail, which is why I ask if you know. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants