How to add a filter to a buddypress hook to change the current time being saved

I am using buddypress together with wordpress. The date/datetime is always saved at the db in GMT/UTC without any offset. This leads to miscalculation cause I want that always the local time is beeing saved cause I am in the Europe timezone. Not sure if this is a bug or not. Anyway, when I set $gmt to off at this bp core function the local time is saved and all works. But its not a good way to modify core. So how can I add a filter to that and set $gmt to FALSE? /** * Get the current GMT time to save into the DB. * * @since 1.2.6 * * @param bool $gmt True to use GMT (rather than local) time. Default: true. * @param string $type See the 'type' parameter in {@link current_time()}. * Default: 'mysql'. * @return string Current time in 'Y-m-d h:i:s' format. */ function bp_core_current_time( $gmt = **true**, $type = 'mysql' ) { // set gmt to false here works /** * Filters the current GMT time to save into the DB. * * @since 1.2.6 * * @param string $value Current GMT time. */ return apply_filters( 'bp_core_current_time', current_time( $type, $gmt ) ); } My attempts: add_filter('bp_core_current_time','current_time2'); function current_time2 () { return current_time($type='mysql',$gmt=false); } This leads to an error saying "Uncaught TypeError: date(): Argument #2 ($timestamp) must be of type ?int, string given..." add_filter('bp_core_current_time','current_time2'); function current_time2 ($gmt) { return $gmt=false; } And this doesn't work, returns a timestamp and saves 0000-00-00 00:00:00 in database.

Comment (0)

You’ll be in good company