Activate and deactivate two plugins automatically at certain hours

Rather than update the database you could write a mu-plugin to intercept reads from the active_plugins option, e.g.

function option_active_plugins_akismet_or_yoast( $plugins )
    if ( !defined('WP_ADMIN') ) {
        $hour = getdate()[ 'hours' ];
        if ( $hour >= 10 && $hour < 19 ) {
        } else {
        $remove_index = array_search( $to_remove, $plugins );
        if ( $remove_index !== false ) {
            unset( $plugins[ $remove_index ] );
    return $plugins;
add_filter( 'option_active_plugins', 'option_active_plugins_akismet_or_yoast' );

This needs to go in a mu-plugin before the plugin load loop. This will leave both active in the admin site and because you’re doing this at runtime there won’t ever be any overlap when both are active. Unhelpfully there isn’t a filter in wp_get_active_and_valid_plugins() to use instead.

I’m assuming these are regular plugins on a regular site and not multisite network-activated plugins. You might need to make the condition ( !defined( 'WP_ADMIN' ) && !wp_doing_ajax() ) too – I haven’t thought about that too hard.

However this is a strange thing to do and you should really fix the conflict between your two plugins instead.