0

This code was inherited from a previous version of our site http://iowacrisischat.org. It's supposed to show one button if it's between 12pm-2am central time, and another button if it's outside of those hours.

It's working on and off in Chrome, and displaying not only the wrong button but an OLD version of the button in IE and Firefox. I've tried deleting my cookies but it still displays an old version of the button that isn't even in the most recent file uploaded to the site.

So I guess a couple questions. 1) Is the time part of the code what's making Chrome inconsistent? Should it be 0-23 instead of 12 hours, does it need to have minutes? 2) Why would IE and Firefox be showing an old version of the code.

Thank you for any help!!

function crisischat()
{
    date_default_timezone_set("America/Chicago");
    $hour        = date('G', time());
    $duringHours = ($hour >= 12 || $hour < 2);
    $isProblem   = FALSE;
    if ($duringHours) {

        echo '<div id="chatbtn"><a href="https://m2.icarol.com/ConsumerRegistration.aspx?org=2133&amp;amp;pid=51&amp;amp;cc=en-US">.Chat Now.</a></div>';
    } else if ($isProblem) {
        echo 'We are experiencing technical difficulties. Please call our crisis line at 1-855-325-4296.';
    } else {
        echo '<div id="chatbtn"><a href="https://m2.icarol.com/ConsumerRegistration.aspx?org=2133&amp;amp;pid=51&amp;amp;cc=en-US">-Chat Now-</a>';

    }
}
crisischat();
Farhan Tahir
  • 2,096
  • 1
  • 14
  • 27
  • Server time may not be in sync with your own. I'd try using a better date library (Carbon - http://carbon.nesbot.com/) – JDev518 May 04 '18 at 18:26
  • Please show the [server response headers](https://stackoverflow.com/q/4423061/1144627) from the different browsers. You can see this information by pressing F12 to open the developer console, and refreshing the page (F5). In the Network Tab, find the page request in the list, click it, and show the headers. More than likely, based on your description of the issue, is that your page is being cached by the browser. – Will B. May 04 '18 at 18:37
  • Cache-Control: max-age=7200 Connection: keep-alive Content-Encoding: gzip Content-Length: 7047 Content-Type: text/html; charset=UTF-8 Date: Fri, 04 May 2018 21:07:34 GMT Expires: Fri, 04 May 2018 18:45:39 GMT Link ; rel=shortlink Server: nginx/1.12.2 Vary: Accept-Encoding X-Acc-Exp: 43200 X-Endurance-Cache-Level: 2 X-Proxy-Cache: HIT www.iowacrisischat.org – soulfrog May 04 '18 at 21:09
  • @fyrye - in Chrome on the developer console I clicked "Disable Cache" and that showed me the correct button. Is there a way to put something in the php code to clear someone's cache for them? Thank you so much for your help! – soulfrog May 04 '18 at 21:13
  • for example: https://stackoverflow.com/questions/13640109/how-to-prevent-browser-cache-for-php-site – Jakumi May 05 '18 at 08:40
  • I ended up asking BlueHost to disable caching and that fixed it. :) – soulfrog May 06 '18 at 11:22

0 Answers0