JSFiddle - React, Tailwind, and code Playground

by j08691

HTML

<p id="resultBday"></p>
<input type="date" name="bday" id="bday" onchange="submitBday()">

JavaScript

function submitBday() {
    var Q4A = "Your birthday is: ";
    var Bdate = document.getElementById('bday').value;
    var Bday = +new Date(Bdate);
    Q4A += Bdate + ". You are " + ~~ ((Date.now() - Bday) / (31557600000));
    var theBday = document.getElementById('resultBday');
    theBday.innerHTML = Q4A;
}