Sleek foundation javascript function.
function calculateAge(birthday) { // birthday is a date
var ageDifMs = Date.now() - birthday;
var ageDate = new Date(ageDifMs); // miliseconds from epoch
return Math.abs(ageDate.getUTCFullYear() - 1970);
}
More Related Contents:
- How do you get a timestamp in JavaScript?
- Incrementing a date in JavaScript
- Check time difference in Javascript
- Browsers, time zones, Chrome 67 Error (historic timezone changes)
- Javascript – get array of dates between 2 dates
- Converting milliseconds to a date (jQuery/JavaScript)
- How to parse JSON to receive a Date object in JavaScript?
- How to get the difference of two dates in mm-dd-hh format in Javascript
- exclude weekends in javascript date calculation
- Javascript format date / time [duplicate]
- JSON Stringify changes time of date because of UTC
- How to get the exact local time of client?
- Converting 24 hour time to 12 hour time w/ AM & PM using Javascript
- How to get the current date or/and time in seconds
- Safari JS cannot parse YYYY-MM-DD date format?
- Get next date from weekday in JavaScript
- Javascript: output current datetime in YYYY/mm/dd hh:m:sec format
- Stop javascript Date function from changing timezone offset
- Age from Date of Birth using JQuery
- How to change date format in JavaScript [duplicate]
- Problem with date formats in JavaScript with different browsers
- Use JavaScript to convert a date string with timezone to a date object in local time
- Work with a time span in Javascript
- How to Convert Persian (Jalali) Dates to other 18 Calendar Dates in Javascript without External Libraries or Complex Astronomical Equations
- Date.toISOString() but local time instead of UTC
- Calculate the UTC offset given a TimeZone string in JavaScript
- JS check for valid date format
- Javascript, Time and Date: Getting the current minute, hour, day, week, month, year of a given millisecond time
- Hot to get incomplete datetime-local input values
- Converting Google spreadsheet date into a JS Date object?