Skip to content

Commit

Permalink
agecalc bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fab3F committed Mar 10, 2024
1 parent 46c5353 commit afc130b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions js/agecalc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ function calculateAge() {
const birthdate = new Date(input.value);
const currentDate = new Date();

birthdate.setHours(0, 0, 0, 0);
currentDate.setHours(0, 0, 0, 0);

const ageMilliseconds = currentDate - birthdate;
const ageYears = ageMilliseconds / (1000 * 60 * 60 * 24 * 365.25);
if(input.value)
Expand Down

0 comments on commit afc130b

Please sign in to comment.