Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Variables
- var now = new Date();
- var totalDays = '';
- var totalMonths = '';
- var totalWeeks;
- var birthDate = new Date(document.getElementById('selYear').value, document.getElementById('selMonth').value, document.getElementById('selDay').value);
- var output = '';
- //Total Days Old
- var totalDays = Math.floor((now - birthDate) / 86400000);
- //Total Weeks Old
- totalWeeks = totalDays / 7;
- totalWeeks = Math.round(totalWeeks);
- //Total Months Old
- totalMonths = totalDays / 30;
- //Total Years
- var totalYears = document.getElementById('selYear').value - now.getFullYear();
- totalYears = Math.abs(totalYears);
- //Outputs
- output += 'You are ' + totalDays + ' days old';
- output += '<br />You are ' + totalWeeks + ' weeks old';
- output += '<br />You are ' + totalMonths + ' months old';
- output += '<br />You are ' + totalYears + ' Years old';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement