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

240
Visualizações
Print True in the console depending on a Specific Date

I am trying to print True in the console when a Specific date comes.

Here is my code :

setInterval(() => {
 if (new Date() == new Date("2022-06-18T06:27:00")) {
   console.log("true");
 } else {
   console.log("false");
 }
}, 1000);

But it keeps showing False

There is another way to do what I am thinking about?

Note: Both of new Date() and the Date which I have provided in the Stamp time are the same on the console

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

0

You can use the following:

setInterval(() => {
 if (new Date().toString() == new Date("2022-06-18T03:32:00").toString()) {
   console.log("true");
 } else {
   console.log("false");
 }
}, 1000);

var date = document.getElementById('date')
    var button = document.getElementById('submit')
    var result = document.getElementById('info')
    var reset = document.getElementById('reset')

    button.addEventListener('click', () => {
        date.disabled = true
        button.disabled = true
    var Timer = setInterval(() => {
            if (new Date().toString() == new Date(date.value).toString()) {
                result.innerHTML = "The date is: " + new Date().toString() + " Which is the same as the date you entered"
                clearInterval(Timer)
                date.disabled = false
                button.disabled = false
                return;
            }
            result.innerHTML = "Waiting for the date..."
           }, 1000);
    });

    reset.addEventListener('click', () => {
        input.disabled = false
        button.disabled = false
        result.innerHTML = "";
    })
<input type="datetime-local" id="date">
<button id="submit">Submit</button>
<button id="reset">Reset</button>
<p id="info"></p>

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