<?php
date_default_timezone_set('America/New_York');
 $currentHour = (int) date('G'); // 24-hour format, 0-23

header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";

if ($currentHour >= 2 && $currentHour < 12) {
    // Working hours (9 AM – 11:59 AM): Try connecting to Web Client
    ?>
<Response>
  <Dial timeout="20" action="Anil_changes/fallback-handler.php" record="record-from-answer-dual">
  <Client   statusCallbackEvent="completed"
          statusCallback='https://havenclean.me/haven/Anil_changes/events.php'
          statusCallbackMethod='POST'>Jonathan</Client>
</Dial>

</Response>
<?php
} else {
    // Outside working hours: Forward directly to phone number
    ?>
<Response>
  <Dial record="record-from-answer-dual">
    <Number>+19179053357</Number>
  </Dial>
</Response>
<?php
}
?>