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

134
Views
How to create an elapsed time calendar in JavaScript

I have the original code, which only allows the user to choose from future dates. However, I would like to change this so that the user can pick a previous date, and it will show the time since then. The if-statement is where it decides if the date is in the past or future. However, even when I remove the entire statement, it allows me to pick a past date but won't print it to the screen.

This is the rest of the code if you are interested/able to help. I understand the snippet doesn't show everything but I don't know what other pieces of code to include. The entirety of the code is simply copied into a Google Doc: cal.js

code snippet:

// select date  
 function selectDate(event) {
    if (event === undefined) { // get caller element in IE8
        event = window.event;
    }
    var callerElement = event.target || event.srcElement;   
    dateObject.setDate(callerElement.innerHTML);
    var fullDateToday = new Date();
    var dateToday = Date.UTC(fullDateToday.getFullYear(),
        fullDateToday.getMonth(), fullDateToday.getDate());
    var selectedDate = Date.UTC(dateObject.getFullYear(),
        dateObject.getMonth(), dateObject.getDate());
    ** if (selectedDate <= dateToday) {
        document.getElementById("cal").style.display ="block";
        return false; 
    } **
    document.getElementById("tripDate").value = 
        dateObject.toLocaleDateString();
    hideCalendar();
    countdown = setInterval(updateCountdown, 1000);
    document.getElementById("countdownSection").style.display = "block";
 }
about 4 years ago · Juan Pablo Isaza
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!