public

Filter time if off by 7 hours

  • Download Gist
buddypress PST time correction
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
 
 
// add 7 hours in the filters below
function shane_local_time( $timestamp ) {
 
$unixTimestamp = strtotime( $timestamp );
$unixTimestamp = $unixTimestamp + (7 * 3600);
$filtered_time = date("Y-m-d H:i:s", $unixTimestamp);
return $filtered_time;
}
 
/**
* Filters the 'last active' screen output
*/
function shane_local_time_last_active( $last_active, $last_activity_date, $string ) {
 
$filtered_time = shane_local_time( $last_activity_date );
$last_active = sprintf( $string, bp_core_time_since( $filtered_time ) );
 
return $last_active;
 
}
add_filter( 'bp_core_get_last_activity', 'shane_local_time_last_active', 1, 3 );
 
 
/**
* Filters the 'time_since' screen output
*/
function shane_bp_activity_time_since( $output, $activity ) {
$filtered_time = shane_local_time( $activity->date_recorded );
$output = bp_core_time_since( $filtered_time );
return $output;
 
}
add_filter('bp_activity_time_since', 'shane_bp_activity_time_since', 1, 2);

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.