Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

241
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda