Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: time zones different in Messages and Forums (bbpress)


3sixty
Participant

@3sixty

OK, starting to solve the issue. I think the root of the problem is that my BP installation is on shared hosting (I know, I know…) and the server time zone is different than my WP installation time. HowEVER, BP Messages is pulling the SERVER time when it INSERTs the message record (bp-messages-classes.php:

// First insert the message into the messages table
if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, FROM_UNIXTIME(%d) )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $this->date_sent ) ) )

I added a variable and changed the query like this:

$wp_current_time = current_time('mysql');
// First insert the message into the messages table
if ( !$wpdb->query( $wpdb->prepare( "INSERT INTO {$bp->messages->table_name_messages} ( thread_id, sender_id, subject, message, date_sent ) VALUES ( %d, %d, %s, %s, %s )", $this->thread_id, $this->sender_id, $this->subject, $this->message, $wp_current_time ) ) )

Now the message inserts correctly using my WP installation time instead of the server time, and REPLIES show up as having the correct time (such as “posted 4 minutes ago”). However…

While REPLIES report time correctly, for some reason, the INITIAL MESSAGE does not. I think that <?php bp_the_thread_message_time_since() ?> is somehow not reporting correctly. Let me check to see what’s wrong with that.

Skip to toolbar