1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to Change the Time and Date Format in Messaging

How to Change the Time and Date Format in Messaging

Introduction

The BuddyBoss messaging feature does not currently include a built-in option to customize how time and date formats are displayed. To adjust this behavior, custom code is required. As a workaround, you can apply a custom function that syncs the message date and time format with the settings defined in your WordPress dashboard. This guide explains how to change the time and date format in messaging.

Custom Workaround

Before proceeding, make sure you have a complete site backup.

  1. Go to Appearance > Theme Editor in your WordPress admin dashboard.
  2. Under Select theme to edit, choose your active theme (preferably a BuddyBoss Child Theme), then click Select.
  3. From the Theme Files list, open Theme Functions (functions.php).
  4. Add the following code just before the closing PHP tag (?>):
function bb_change_date_format_to_wp_date( $output ) {
    $date_format = get_option( 'date_format' );
    if ( empty( $date_format ) ) {
        return $output;
    }
    return date_i18n( $date_format, strtotime( $output ) );
}
add_filter( 'bb_get_thread_start_date', 'bb_change_date_format_to_wp_date' );

function bb_change_time_format_to_wp_time( $site_sent_date ) {
    if ( function_exists( 'bp_get_the_thread_message_date_sent' ) ) {
        $sent_date = bp_get_the_thread_message_date_sent();
        $sent_date_formatted = wp_date( 'Y-m-d h:i:s', $sent_date );
        $site_sent_date = get_date_from_gmt( $sent_date_formatted );

        $time_format = get_option( 'time_format' );
        $time_format = ! empty( $time_format ) ? $time_format : 'g:i a';

        $site_sent_date = wp_date( $time_format, strtotime( $site_sent_date ) );
    }
    return $site_sent_date;
}
add_filter( 'bb_get_the_thread_message_sent_time', 'bb_change_time_format_to_wp_time', 99, 1 );

  1. Click Update File to save the changes.

Once the code has been added successfully, navigate to WordPress Admin > Settings > General. From there, update your preferred Date Format and Time Format. The messaging timestamps will now reflect those settings.

Note: Modifications are typically considered custom work, but we are making an exception in this case. Please review the BuddyBoss Support Policy.

Troubleshooting and FAQs

Q: Where do I change the date and time format after adding the code?
A: Go to Settings > General in your WordPress dashboard and update the Date Format and Time Format fields.

Q: Will this affect other parts of my site?
A: Yes. The formats used here are pulled from the global WordPress date and time settings, which may also affect other areas that rely on those settings.

Q: Does this apply to existing messages?
A: Yes. Existing message timestamps will display using the updated format.

Q: Is this officially supported by BuddyBoss?
A: No. This solution is a custom workaround and not part of the default BuddyBoss feature set.

Was this article helpful?

Related Articles

Subscribe to Our Newsletter

Stay In Touch

Subscribe to our Newsletter, and we’ll send you the latest news from BuddyBoss

  • This field is hidden when viewing the form
  • This field is for validation purposes and should be left unchanged.

To speak to our Agency consultant, fill in the form found at our Contact Page.

  • Get Started

    Enter your name and email address to get started with your project...

  • This field is for validation purposes and should be left unchanged.