WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display During Certain Day and Time (2 posts)

  1. Aikyrie
    Member
    Posted 1 year ago #

    I've tried just about everything and I'm stumped! I'm trying to display an image only during one day of the week between certain hours. Here's my code:

    <?php if (time() >= strtotime('Tuesday, 11:00 AM') && time() <= strtotime('Tuesday, 05:00 PM')) { ?>
    DISPLAY IMAGE
    <?php } ?>

    I've tried this on a PHP file by itself and it seems to work. Any ideas?

  2. Aikyrie
    Member
    Posted 1 year ago #

    I was able to do it with the following:

    <?php $c_time = mktime();
    $open = strtotime('Saturday 1pm');
    $close = strtotime('Saturday 8pm');
    if ($c_time > $open && $c_time < $close) { ?>
    
    CONTENT HERE
    
    <?php } ?>

    [Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

Topic Closed

This topic has been closed to new replies.

About this Topic