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,931
  • Total Topics: 21,311
  • Online today: 1,324
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 323
  • Total: 324
  • lurkalot

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!

This website is proudly hosted on Crocweb Cloud Website Hosting.