0

I have this PHP code in one template (contact.html):

<?php
    $on  = 830;
    $off = 1730;
    $now = intval(date("Gi"));
    echo "<!-- ".$now."-".$on."-".$off." -->";
    if($now > $on && $now < $off) {
?>
    <!-- the HTML I want to hide by time is located here -->
<?php
    }
?>    

and this code in another template (footer.html) that is embedded in the contact template above:

{if "{segment_1}" == "contact"}
<?php
    $on  = 0830;
    $off = 1530;
    $now = intval(date("Gi"));
    echo "<!-- ".$now."-".$on."-".$off." -->";
    if($now > $on && $now < $off) {
?>
    <!-- the HTML I want to hide by time is located here -->
<?php
    } 
?>
{/if}

As you see, I echo out the values in both templates. When I load the page at 7:08am, I get this comment in the code for the contact template and the html is hidden just like planned:

<!-- 708-830-1730 -->

But in the code in the footer template, I get this comment and the html shows instead of being hidden:

<!-- 1208-830-1730 -->

Why the differences???

0

1 Answer 1

1

Is this on a load balanced server solution? Have you doubled checked that both the agent and the CLI php.ini files have the same setting for time zone? Try using this command before both date grabs (set it to your local timezone):

date_default_timezone_set('America/Los_Angeles');

Do you start seeing consistent reporting? If so, it's likely an inconsistency in timezone settings somewhere. Especially since the time difference is exactly 5 hour, I would bet that's your issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.