PHP 12
Redirect code as of 9/2/2025 Guest on 2nd September 2025 10:52:15 PM
  1. <?php
  2. date_default_timezone_set('America/New_York');
  3. $current_time = date('H:i:s');
  4. $day_of_week = date('l');
  5.  
  6. function performRedirection($time, $day) {
  7.     // Function to check if the current time is between 10:00 AM and 5:30 PM
  8.     function isTimeBetween($time) {
  9.         $start_time = strtotime('09:00:00');
  10.         $end_time = strtotime('21:00:00');
  11.         $current_time = strtotime($time);
  12.         return ($current_time >= $start_time && $current_time <= $end_time);
  13.     }
  14.  
  15.     // Set common headers for all cases
  16.     header('Cache-Control: no-cache, no-store, must-revalidate');
  17.     header('Pragma: no-cache');
  18.     header('Expires: 0');
  19.  
  20.     // Check the day of the week and time
  21.     switch ($day) {
  22.         case 'Saturday':
  23.         case 'Sunday':
  24.             // Redirect the user to a different URL with a temporary (302) redirect and HTTPS
  25.             header('Location: https://tiny.cc/csitschedule', true, 302);
  26.             exit;
  27.             break;
  28.  
  29.         default:
  30.             if (isTimeBetween($time)) {
  31.                 // Redirect the user to the first URL with a temporary (302) redirect and HTTPS
  32.                 header('Location: https://forms.gle/ia74VKh36EG6tqyo6', true, 302);
  33.                 exit;
  34.             } else {
  35.                 // Redirect the user to the second URL with a temporary (302) redirect and HTTPS
  36.                 header('Location: https://tiny.cc/csitschedule', true, 302);
  37.                 exit;
  38.             }
  39.             break;
  40.     }
  41. }
  42.  
  43. performRedirection($current_time, $day_of_week);
  44. ?>

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.