@LouMauriege
Posted
Hi! You made a pretty good job yet.
To calculate difference between two dates you can create two dates and subtract them.
You create the variable date on script.js.line.16, you can create another on with the input values that the user gives you. Then you can subtract those dates, and you'll have the difference between those two dates in milliseconds. After that you just had to divide, this result with the number of milliseconds in one year and the result of it should be the years between your two dates. Then take the modulo of this division and divide it with the numbers of milliseconds in one month and so on till you get the years, month and days between your two dates.
Hope it will help you :)
Marked as helpful
@OUSSAMAACHICHE
Posted
@LouMauriege Thanks for this valuable help , Can you explain to me the simple code? π€·ββοΈ
@LouMauriege
Posted
@OUSSAMAACHICHE
Ok, I think that the best code to explain this to you might the code of @HaarithBinSabur go check the github repo to see how he did it. In this ( https://github.com/HaarithBinSabur/age-calculator-component/blob/main/app.js ) javascript file from the line 27 to the line 33, you'll see his method witch is mostly the best one to explain how to calculate age from milliseconds.
Hope it will help feel free to ask more questions if needed ;)
Marked as helpful
@OUSSAMAACHICHE
Posted
Thank you soo much π@LouMauriege
@LouMauriege
Posted
@OUSSAMAACHICHE It's allways a pleasure to help, and it also making me learn a lot so it's a win win.