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 3799000
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:39:50+00:00 2026-05-19T13:39:50+00:00

Goal: To create a countdown to our next available live stream. Details: We live

  • 0

Goal:
To create a countdown to our next available live stream.

Details:
We live stream six times a week all (PST).

1. Sunday at 8:00 a.m.
2. Sunday at 10:00 a.m.
3. Sunday at 12:00 p.m.
4. Sunday at 6:30 p.m.
5. Wednesday at 7:00 p.m.
6. Saturday at 10:00 a.m.

My approach:
Originally I check what day it is and what time it is then create the countdown to the next stream. This works fine for our timezone (PST) and any that are relatively close.

Problem:
Checking first the day breaks my approach for people in timezones that put them a day ahead of us. For example if someone from London checks the site on Thursday at 2:30 a.m. (GMT) my code would start the countdown to the Saturday 10:00 a.m. stream instead of the Wednesday at 7:00 p.m. (PST) which would start in 30 mins.

I’m sure what I have done can be cleaned up and improved, tell me how.

My code:

// Countdown
function countDown( addDay, hour, min ) {
    var newCount = new Date(); 
    newCount = new Date(newCount.getFullYear(), newCount.getMonth(), newCount.getDate() + addDay, hour, min); 
    $('#service_countdown').countdown({until: $.countdown.UTCDate(-8, newCount)}); 
}

var day_ref, day, addDay, hour, min;
addDay = 0;
hour = 0;
min = 0;
day = {};

day_ref = new Date();
day = {"day" : day_ref.getDay(), "hour" : day_ref.getHours(), "min" : day_ref.getMinutes()};

// It's Sunday
if ( day.day === 0 ) {

    if ( day.hour < 8 ) {
          hour = 8;
        countDown(addDay, hour, min);
    } 
    else if ( day.hour < 10 ) {
          hour = 10;
        countDown(addDay, hour, min);
    } 
    else if ( day.hour < 12 ) {
          hour = 12;
        countDown(addDay, hour, min);
    }
    else if ( day.hour <= 18 && day.min < 30 ) {
          hour = 18;
           min = 30;
        countDown(addDay, hour, min);
    } 
    else {
        addDay = 3;
          hour = 19;
        countDown(addDay, hour, min);
    }
} 
// It's Monday
else if ( day.day === 1 ) {
    addDay = 2;
      hour = 19;
    countDown(addDay, hour, min);
} 
// It's Tuesday
else if ( day.day === 2 ) {
    addDay = 1;
      hour = 19;
    countDown(addDay, hour, min);
} 
// It's Wednesday
else if ( day.day === 3) {

    if ( day.hour < 19 ) {
          hour = 19;
        countDown(addDay, hour, min);
    } else {
        addDay = 3;
          hour = 10;
        countDown(addDay, hour, min);
    }
} 
// It's Thursday
else if ( day.day === 4 ) {
    addDay = 2;
      hour = 10;
    countDown(addDay, hour, min);
} 
// It's Friday
else if ( day.day === 5 ) {
    addDay = 1;
      hour = 10;
    countDown(addDay, hour, min);
} 
// All that's left is Saturday
else {

    if ( day.hour < 10 ) {
          hour = 10;
        countDown(addDay, hour, min);
    } else {
        addDay = 1;
          hour = 8;
        countDown(addDay, hour, min);
    }
}

Thanks in advance for any help!

  • 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-05-19T13:39:51+00:00Added an answer on May 19, 2026 at 1:39 pm

    I ended up just doing all the time calculating server side. With the help of bob-the-destroyer the working php is quite compact given the requirements.

    <?php
    
    $schedule = array(
        'this Sunday 8am',
        'this Sunday 10am',
        'this Sunday 12pm',
        'this Sunday 6:30pm',
        'this Wednesday 7pm',
        'this Saturday 10am'
        );
    
    $current_time = strtotime('now');
    foreach ($schedule as &$val) {
        $val = strtotime($val);
        // fix schedule to next week if time resolved to the past
        if ($val - $current_time < 0) $val += 604800; 
        }
    sort($schedule);
    $countdown = $schedule[0] - $current_time;
    
    ?>
    
    <script type="text/javascript">
        var myTime = <?php echo $countdown; // just personally prefer full tags ?>;
        $('#countdown').countdown({ until: myTime}); 
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Goal: Create Photomosaics programmatically using .NET and C#. Main reason I'd like to do
The goal: To create a .NET dll i can reference from inside SQL Server
My goal here is to create a very simple template language. At the moment,
For example my table is here>> CREATE TABLE tProject( name nvarchar(1000), Goal ntext, Activities
my goal is to write a stored proc that can collect all field values
Duplicate: PHP validation/regex for URL My goal is create a PHP regex for website
my goal: create an image gallery with each image having a description, name, title,
My goal is to create a generic function that selects a value in a
The end goal is to create a helper found at the end called show_status(contact,event).
Goal I want to create a web app with a horizontal GUI bar that

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.