Redirect page during a weekly time interval


I have a registration page ‘register’ which sends information to a third party server as part of a dual registration process. The 3rd party have a 2 hr weekly maintenance schedule every Friday 9-11pm CT. I wish to redirect users to a new page that just says you can’t register during this specified maintenance time period.

I am considering using the below added to functions.php. Is this the right approach, does it look like it would work? I don’t want to reset the entire site’s time zone either, as not in America, just for this usage.

add_action ( 'template_redirect', 'redirect_from_registration_maintenance' ); function redirect_from_registration_maintenance(){     date_default_timezone_set('America/Chicago');     $  hour = date('G');     $  minute = date('i');     $  day = date('w');     $  m = $  hour * 60 + $  minute; // Minutes since midnight. if ( !is_user_logged_in() && is_page( 'register' )   && $  day == 5 // Friday...   && $  m >= 1260 // ... after 9pm…   && $  m <= 1380 // ... but before 11pm… ) {     wp_redirect('https://www.example.com/maintenance_notice') ; exit();     } } 

Thanks