/*Reverse sticky header*/
  1. Home
  2. Knowledge Base
  3. Customizations
  4. PHP Functions
  5. How to change the time and date format on the messaging?

How to change the time and date format on the messaging?

Please be informed that changing the time format display on the messaging feature is not available on our platform. For now, custom work is needed to achieve this feature. However, as an exception, our team was able to create a workaround to achieve this feature.

1. Go to Appearance > Theme Editor.

2. Under “Select theme to edit”, choose (BuddyBoss Child/whatever theme is active), then click “Select”.

3. Below Theme Files, select Theme Functions (functions.php).

4. Append the 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 );

This custom code will get the WP date and time format for the message thread.

Once you have entered the code and saved successfully in your themes functions.php file, you can then navigate to your WordPress Admin – Settings – General. From here you can select the time and date format you prefer which will then amend the time and date format in your message

Was this article helpful?

Related Articles

Need Support?

Can't find the answer you're looking for?
Support

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

"*" indicates required fields

Get Started

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

Name*