Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7848767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:19:17+00:00 2026-06-02T18:19:17+00:00

I’m not very good at code so please use laymans terms in answering!! I

  • 0

I’m not very good at code so please use laymans terms in answering!!

I have broadcast site where I hide links until a specific time of day (i.e. broadcast time) this is the code I use to do this:

<?php
date_default_timezone_set('Europe/London');
$currtime = date('Hi');
// Change time
$starttime = 2200;  
$endtime = 2300; 
$endtime = $endtime + 2400;
$endtest = $currtime + 2400;

?>
<?php

if( $currtime >= $starttime && $endtest <= $endtime ){
?>
<a href="*broadcastlink*">LIVE NOW</a>
<?php
}
else{
?>
Live at 22:00
<?php
}
?>

Currently users have to refresh the page manually which is a bit messy.

I know this could be done easily using javascript to refresh the whole page every x seconds but I don’t want to do this as I have another piece of code that shows a “facebook like” popup window that doesn’t close for 5 minutes unless they click like, so refreshing the whole page would constantly show the popup window.

Please can someone write a script so that I can link a refresh script to the php script above so that at the link reveal time the container refreshes, I’ve looked around and found nothing suitable so far?

Thanks in advance for any help – much appreciated

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T18:19:22+00:00Added an answer on June 2, 2026 at 6:19 pm

    bad news is PHP cannot force browser to do anything. you need javascript with ajax to achieve this. but what if javascript is disabled in client side. there is a small trick in php .

    here is what you can do.

    determine the number of seconds for the live broadcast to start by doing

    $numOfSeconds = $starttime - $currtime;
    

    then once you know after how many seconds you want to refresh your browser here is how you can do it with php.

    header( "refresh:$numOfSeconds;urltoanywhere.php" );
    

    this will take you to any url you wish to go after specific time. define the url to the same page if you wish to refresh. and you could extend this logic to implement the way you want to.

    Update1:

    Below is the working code which i have tested. hope this helps you 🙂

    <?php
    ob_start();
    date_default_timezone_set('Europe/London');
    $currentPage = $_SERVER['PHP_SELF'];
    $currentTimestamp = strtotime(date('Y-m-d H:i:s'));
    //Define your startTime here in {Year-Month-Day Hour:Minute:Second} format
    $startTime = '2012-04-26 21:57:00';
    //Define your endTime here in {Year-Month-Day Hour:Minute:Second} format.
    $endTime = '2012-04-27 22:00:00';
    $startTimestamp = strtotime($startTime);
    $endTimestamp = strtotime($endTime);
    $numOfSecondsToReload = $startTimestamp - $currentTimestamp;
    if($currentTimestamp >= $startTimestamp && $currentTimestamp <= $endTimestamp):
    ?>
    <a href="*broadcastlink*">LIVE NOW</a>
    <?php else: ?>
    <p>Live at <?php echo date('H:i', $startTimestamp); ?></p>
    <?php header( "refresh:$numOfSecondsToReload;$currentPage"); ?>
    <?php endif; ?>
    

    Update2: to reload specific div content. here is the code you can use.

    <div id="live">
        <?php
        ob_start();
        date_default_timezone_set('Europe/London');
        $currentPage = $_SERVER['PHP_SELF'];
        $currentTimestamp = strtotime(date('Y-m-d H:i:s'));
        $startTime = '2012-04-27 12:42:20';
        $endTime = '2012-04-28 22:00:00';
        $startTimestamp = strtotime($startTime);
        $endTimestamp = strtotime($endTime);
        $numOfSecondsToReload = $startTimestamp - $currentTimestamp;
        if($currentTimestamp >= $startTimestamp && $currentTimestamp <= $endTimestamp):
        ?>
        <a href="*broadcastlink*">LIVE NOW</a>
        <?php else: ?>
        <p>Live at <?php echo date('H:i', $startTimestamp); ?></p>
        <?php endif; ob_end_flush(); ?>
        <div id="timeremaining" hidden><?php echo $numOfSecondsToReload * 1000; ?></div>
    </div>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
    <script type="text/javascript">
        var numOfMiliSecondsToReload = $('#timeremaining').html();
        var timeToReload = (numOfMiliSecondsToReload >= 0) ? numOfMiliSecondsToReload : 86400000;
        $(function() {
            $(function() { setTimeout( reloadDiv, timeToReload ); });
            function reloadDiv() { $('#live').load(location.href);}
        });
    </script>
    

    hope this helps you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.