TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,964
  • Latest: stylix
Stats
  • Total Posts: 195,966
  • Total Topics: 21,317
  • Online today: 2,741
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 542
  • Total: 542

Automated Blocks

Started by Sledge, February 08, 2026, 10:15:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Sledge

Hi. I'm not a html/php coder so I thought I'd ask here.

Is there a way to code a block so that it's contents only show in a specific time frame? I have a banner, but I'd only like it to show on Mondays between 7pm and 11pm. Is this possible? Here's what I have now (BBC block).

[center][color=red][size=3][b]Itchdog is currently live on the air!![/b][/size][/color][/center]
[center][url="http://www.southbayradio.org/"]Click here to tune in![/url][/center]

[center][url="http://www.southbayradio.org/"][img]https://evolvedones.net/gallery/1_02_02_26_8_09_39.png[/img][/url][/center]

I don't mean recoding Tinyportal, but making a html/php script in the actual block that will ignore the contents unless it's during that time frame.

<html>If the time date is outside (time/date) then ignore the rest of this block</html>

lurkalot

You could try this in a PHP block.  Set block to "Do not use title/frame styles" and "Do not allow block to collapse"

I've set the day and time for you, but you'll need to add your image link at the bottom.

// --- SETTINGS ---
$target_day = 1;   // 0=Sunday, 1=Monday, 2=Tuesday... 6=Saturday
$start_time = "19:00";
$end_time   = "23:00";

// --- CURRENT DATE/TIME ---
$now = new DateTime("now", new DateTimeZone("Europe/London"));
$current_day = (int)$now->format("w");
$current_time = $now->format("H:i");

// --- CHECK ---
if ($current_day === $target_day && $current_time >= $start_time && $current_time < $end_time) {
    echo '<img src="https://your-image-url-here.jpg" alt="Scheduled Image">';
}


Sledge

#2
YES!! That works perfectly! Thank you  :)

You're brilliant!

Kernal

#3
here is the HTML version below that is responsive too below Kernal Coded 2026!

<!-- TinyPortal Simple Multi-Time Banners Kernal Coded 2026 -->
<div id="tpBanners" style="text-align:center; margin:10px 0;"></div>

<script>
(function() {
    var now = new Date();
    var currentDay = now.getDay();  // 0=Sun, 1=Mon...
    var currentHour = now.getHours(); // 0-23

    // ===== CONFIGURE YOUR BANNERS HERE OK =====
    var banners = [
        {
            image: "BANNER1-IMAGE.jpg",
            day: 1,      // Monday
            start: 19,   // 7pm
            end: 23      // 11pm
        },
        {
            image: "BANNER2-IMAGE.jpg",
            day: 5,      // Friday
            start: 18,   // 6pm
            end: 22      // 10pm
        }
        // Add more banners here as needed simple
    ];
    // ========================================

    var container = document.getElementById("tpBanners");

    banners.forEach(function(banner) {
        if(currentDay === banner.day && currentHour >= banner.start && currentHour < banner.end){
            var div = document.createElement("div");
            div.style.margin = "10px 0";
            div.style.textAlign = "center";
            div.innerHTML = '<img src="' + banner.image + '" alt="Event Banner" style="max-width:100%; height:auto;">';
            container.appendChild(div);
        }
    });

})();
</script>

░█░█░█▀▀░█▀▄░█▀█░█▀█░█░░
░█▀▄░█▀▀░█▀▄░█░█░█▀█░█░░
░▀░▀░▀▀▀░▀░▀░▀░▀░▀░▀░▀▀▀

This website is proudly hosted on Crocweb Cloud Website Hosting.