Days Calculator between the dates: The apparatus on this page is utilized to ascertain the time distinction between the two dates. The outcome given incorporates data about how long, months are between the given dates. Also, precisely how long, months, and days there are.

Utilizing this day’s number cruncher is exceptionally simple. Enter two dates from and to in the structure fields (Start date and End date). The dates ought to be entered in the accompanying configuration: DD/MM/YYYY (for example 01/11/2020). In the wake of tapping on any of the structure handles, a schedule will show up, which will make it simpler to choose the proper day. Obviously, the date can likewise be entered utilizing the console.

 

Live Demo

 

Custom Dropdown
FROM TO
Days Remaining
00:00:00

How to use a calculator?

The day’s number cruncher permits you to compute precisely how old you are. You can see precisely how long you as of now have. The age given in days is frequently utilized when discussing infants.

You can check how long are left until an occasion (for example a birthday).

 

Example

 

In the wake of entering in the field Start date the date 01/11/2020 and in the field End date the date 25/07/2021, the outcome will be gotten:

The contrast between the dates is:

265d days

(this is how long, months, and days I have when I make this page ;))

How to check how long are left until your birthday? You should simply enter the present date in the field Start date and your next birthday in the field End date. This way you will know precisely how long your birthday will be in.

On Facebook 

HTML

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Days Calculator
    </title>
  </head>
  <body>
    <div class="container">
      <div class="result">
        <div class="calendar">
          FROM 
          <input type="date" id="fromDate"> TO 
          <input type="date" id="toDate">
          <button id="calculate" onclick="calculateNow();">Calculate Now
          </button>
        </div>
        <div class="NumberOfDaysRemaining">
          Days Remaining
        </div>
        <div class="time" id="demo">
          00:00:00
        </div>
      </div>
    </div>
  </body>
</html>

 

CSS

 .result {
            width: 99%;
            font-size: 50px;
            font-family: -webkit-pictograph;
            display: flex;
            justify-content: center;
            height: 90vh;
            align-items: center;
            border: 5px solid grey;
            background-color: #ecd2d2;
            flex-direction: column;
        }
        
        .calendar {
            font-size: 15px;
            text-align:center
        }

 

Javascript

const calculateNow = () => {
    let currentDate = new Date();
    let time = currentDate.getHours() + ":" + currentDate.getMinutes() + ":" + currentDate.getSeconds();
    let toDate = document.getElementById('toDate').value;
    let fromDate = document.getElementById('fromDate').value + ' ' + time;
    if (toDate != '' && fromDate != '' && fromDate <= toDate) {
        document.getElementById("demo").innerHTML = "";
        let countDownDate = new Date(toDate).getTime();
        // Get todays date and time
        let now = new Date(fromDate).getTime();
        // Find the distance between now an the count down date
        let distance = countDownDate - now;
        // Time calculations for days, hours, minutes and seconds
        let days = Math.floor(distance / (1000 * 60 * 60 * 24));
        let hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
        let minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
        let seconds = Math.floor((distance % (1000 * 60)) / 1000);

        // Display the result in the element with id="demo"
        document.getElementById("demo").innerHTML = days + "d " + hours + "h " +
            minutes + "m " + seconds + "s ";

        // If the count down is finished, write some text 
        if (distance < 0) {
            clearInterval(x);
            document.getElementById("demo").innerHTML = "EXPIRED";
        }
    } else {
        alert('From Date and To Date Should be Valid');
    }
}

You can also see realted post

here

Please follow and like us: