Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

239
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!