Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created February 29, 2024 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/2c66cedca89ebc96ba5b4db026e0ec84 to your computer and use it in GitHub Desktop.
Save KaineLabs/2c66cedca89ebc96ba5b4db026e0ec84 to your computer and use it in GitHub Desktop.
BuddyPress - Youzify Change Time Stamp Format both for Comments and Posts:
<?php
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("Y-m-d H:i", 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 = '<span class="time-since">' . date_i18n("F j, Y", strtotime(
$activities_template->activity->current_comment->date_recorded ) ) . '</span>';
return $date_recorded;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment