Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

136
Visualizações
10 mins countdown timer run continuously for all

I am trying to make a 10 mins countdown timer. That timer should run continuously for everyone. It should not start from the 9.59.59 always. I tried many ways but was not successful. So I need help.

/* return the text name of the day of the week from the day #
*/

function DayNameFromDOW(dDate) {
  var weekday = new Array(7);
  weekday[0] = "Sunday";
  weekday[1] = "Monday";
  weekday[2] = "Tuesday";
  weekday[3] = "Wednesday";
  weekday[4] = "Thursday";
  weekday[5] = "Friday";
  weekday[6] = "Saturday";
  return weekday[dDate.getDay()];
}

function NextWebinarDateandTime() {
  CurDate = new Date();
}

var twoDaysFromNow = new Date().getTime() / 1000 + 86400 * 2 + 1;    
document.addEventListener("DOMContentLoaded", () => {
  NextWebinarDateandTime();    

  var CurrentDayOfWeek = CurDate.getDay();
  var CurrentHours = CurDate.getHours();
  var CurrentMinutes = CurDate.getMinutes();
  var CurrentSeconds = CurDate.getSeconds();

  // what's the first hour of day we want to run a webinar?
  FirstHour = 9;
  LastHour = 11;    

  FirstDOW = 1;
  LastDOW = 1;

  /* set the next webinar to the top of the next hour */
  NextWebinar =
    CurDate.getTime() / 1000 +
    (600 - CurrentMinutes * 60) +
    (60 - CurrentSeconds);

  var nSecsUntilNextWebinar =
    800 - CurrentMinutes * 60 + (60 - CurrentSeconds);

  var d = new Date();

  //  d.setTime(n);
  // new Date(CurDate.getTime());
  document.getElementById("CurDate").innerHTML = CurDate;
  document.getElementById("CurDategetTime").innerHTML = d.getTime();

  document.getElementById(
    "nSecsUntilNextWebinar"
  ).innerHTML = nSecsUntilNextWebinar;
  document.getElementById("nextwebinardateandtime").innerHTML = Date(twoDaysFromNow);    

  // Set up FlipDown
  var flipdown = new FlipDown(NextWebinar)

    // Start the countdown
    .start()

    // Do something when the countdown ends
    .ifEnded(() => {});
});

Here is my code in codepen : https://codepen.io/themeix/pen/OJjdwJp

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You should count down to specific time in future instead of current time + X

Look at this script

function getTimeRemaining(endtime){
  const total = Date.parse(endtime) - Date.parse(new Date()); // Convert time variables to miliseconds and substract them.
  const seconds = Math.floor( (total/1000) % 60 );
  const minutes = Math.floor( (total/1000/60) % 60 );
  const hours = Math.floor( (total/(1000*60*60)) % 24 );
  const days = Math.floor( total/(1000*60*60*24) );

  return {
    total,
    days,
    hours,
    minutes,
    seconds
  };
}

const deadline = 'December 31 2021 23:59:59 GMT+0200';
getTimeRemaining(deadline).minutes // You can call your function this way because it return object

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda