calculate age js

Solutions on MaxInterview for calculate age js by the best coders in the world

showing results for - "calculate age js"
Lorenzo
25 Nov 2018
1function getAge(dateString) 
2{
3    var today = new Date();
4    var birthDate = new Date(dateString);
5    var age = today.getFullYear() - birthDate.getFullYear();
6    var m = today.getMonth() - birthDate.getMonth();
7    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) 
8    {
9        age--;
10    }
11    return age;
12}
Adelene
16 Apr 2016
1const calAge = (date) => new Date(Date.now() - new Date(date).getTime()).getFullYear() - 1970;
2
Homer
10 Mar 2018
1// To calculate age:
2var year_born = prompt("Please enter your date of birth:", "Type here");
3var d = new Date();
4var n = d.getFullYear();
5function getAge(birthYear){
6	var currentDate = new Date();
7    var currentYear = currentDate.getFullYear();
8    age = currentYear - birthYear;
9    return age;
10}
11calculatedAge = getAge(year_born);
12alert("Hello, " + "you are " + calculatedAge + " years old!");
Roberta
10 Mar 2019
1function Person(dob) {
2  // [1] new Date(dateString)
3  this.birthday = new Date(dob); // transform birthday in date-object
4  
5  this.calculateAge = function() {
6    // diff = now (in ms) - birthday (in ms)
7    // diff = age in ms
8    const diff = Date.now() - this.birthday.getTime(); 
9    
10    // [2] new Date(value); -> value = ms since 1970
11    // = do as if person was born in 1970
12    // this works cause we are interested in age, not a year
13    const ageDate = new Date(diff); 
14    
15    // check: 1989 = 1970 + 19
16    console.log(ageDate.getUTCFullYear()); // 1989
17    
18    // age = year if person was born in 1970 (= 1989) - 1970 = 19
19    return Math.abs(ageDate.getUTCFullYear() - 1970);
20  };
21}
22var age =new Person('2000-1-1').calculateAge();
23console.log(age); // 19
24
Leopold
17 Nov 2016
1calculate Age using Javascript
Evelina
20 Jan 2020
1<!DOCTYPE html>
2<html>
3<head>
4  <meta charset="utf-8">
5  <title>JavaScript program to calculate age</title>
6</head>
7<body>
8
9</body>
10</html>
11
12
queries leading to this page
javascript get current ageget age from now and birth date javascriptjavascript calculate age from date of birthcalculate age based on date of birth using javascriptjavascript date get agejs birthday to agehow to calculate age by values entered javascriptdate born to now jsjavascript calculate age in yearsjavascript get age by birth datehow pass date of birth in function in jsjs how to calculate your agedate of birth javascripthow to calculate age from date of birth javascriptjs calsulacte 1 2 of my agehow to calculate date of birth from age in javascriptjs know how old someone iscalculate age using form jsbirthdate from age in jsage calculate using jscalculate age today in dayjsget age show date of birth jsage calculator onlineage calculation using date of birth in javascripthow to calculate age from date of birth jsjavascript get the age from datewrite a function that take birth date and returns age in years 2c months and days jscalculate age from date of birth nodejsprogramme js calculate agedate of birth how to generate age jshow to calculate age from date of birth in html5check age number in javascript function htmlhow to check age with date of birth with out using javascript predefine functionsget age from date javascriptfind how old with function jsjavascript calculate age from birthdatehow to make a age shower in javascriptjavascript html get agecalculate age from date of birth in node jscreate a javascript function with the name age 28 29 this function will take your date of birth as parameters and return your age in years calculate age from dob jshow to check age with date of birth in javascriptcalculate age in days javascriptjs calculate agejavascript display current agejavascript age from birthdatejs according to bday ageage caclulator in jscalculate age js datesjavascript compute agehow to add age to a birthdate jshow can i show my birth days in javascriptage from date function javascriptjavascript current ageage calculat birthdate jstakes the age in years and returns the age in days javascriptcalculate age from date of birth in htmljavascript calculate age in years from date of birthjavascript calculate age using arrow functioncalculate age in javascript from date of birthcalculate age from date of birth jscompare value to the date 28 29 to obtain age javascriptjavascript age from date of birthjavascript function take birthdate and return age get years by age jsconvert date to age javascriptjs get age from datecheck specific age based on day jshow to calculate age from date parse valuesget year with a birth date to methods javascripthow to count age by date of birth in vuejs site 3astackoverflow comjavascript find age from birthdateage calculator in jsavascript calculate age by date of birthfrom date to age function javascriptage calculate in javascriptjavascript function to calculate age from date of birth entered in a datepickerjavascript date of birthyear calculator for age code in javascriptage calculatoe in jsinput your dob 28date 29 through prompt for example date is 2224 22calculate age by date of birth javascriptcalculate age by date of birth javascripcalculate age javascript date birthcheck age based on date of birth in javascriptjavascript age difference validationfind age in jsclacualting age in jshow to determine age by dateof birth javascriptjs calculate age from date of birthage field in javascriptjavascript how do i findout my current agefind age from dob jsage from date javascriptcalculate date of birth from age in javascript and return only valueget age from date of birth jsage calculator js codejavascript age calculationjavascript birthday calculatorcalculate age from birthdate javascriptcalculate age from year of birth in javascripthow to make age calculate in javascriptjavascript calculate age in years 2c months daysjavascript function to calculate age in yearage calulator in javascriptjavascript age functioncheck age number in javascript functioncalculate age in days using date of birth in javascripthow to calculate the age from date of birth in javascriptcalculate age from dob javascriptcalculate age from dob in javascriptcalculate age based on date of birth in javascriptfunction that get age in javascriptget age with day jsjavascript function to calculate age in daysjavascript calc my agecalculate age values given in javascriptfind the age in javascriptcalculate age with todays age node jsget date of birth from user html jsget age by string value in javascriptconvert age in years return age in days javascriptget age javascriptage calculate formula jsage calculate jsget age from dob jsget age methd javascriptjs get age from birthdatejavascript calculate someones agehow to calculate your age for future years jsjavascript age of person based on birth datecalculate age from date of birth 2c jqueryjavascript calculate age fromid numberjavascript date of birth to agejavascript date to agecalculate age with jscalculate dob from age in javascriptcalculate birthdate from age jshow to get age from date of birth javascriptjs to calculate agehow to calculate age with jssave age in javascriptjavascript function to display agecalculate age from date of birth in javascript hijricalculate age in javascriptjavascript 27 27 3e function to calculate age from date of birth entered in a datepickercount age javascripthow to get the age of given birth date in javascript 22automatically calculate age from date of birth javascriptjavascript calc agedob jsjs calc ageget age js with mouthsages based on dates vuejsfunction to calculate age in javascripthow to calculate age in jsbirthday to age javascriptjs calculate age from date of birth cleanhow to get year from dob in javascriptget age from year jscalculate age from date of birth in javascriptjavascript calculate age from dateage calculation formula in javascriptget current age by birthday jsage 2b 2b javascriptjavascript calculate age based on date of birthdayjs calculate ageget your age javascripthow t o calculate age from current date in javascriptreturn age from date jsjavascript calculate age from year of birthget year of birth from age javascriptjs date from birthcalculating age in javascript through date functionjavascript work out age from date of birthcalculate age using date jsjs calculate age by datefunction to check age in javascript date to age jsage calculation in javascriptage calculation in jsget age dayjsjs dob to yearscalculate age from date of birth javascriptes6 calculate agehow to get age in javascriptfind out age from date of birth in javascriptcalculate age from date of birthgestational age calculator by javascriptage calculator javascript codehow to print age date of birth in javascriptfrom age to date of birth javascripthow to calculate current age from date of birth in javascript only yearshow to calculate age in days in javascript using returnhow to find age today in javascriptget your age using dates jsyear of birthday calculator javascriptauto calculate age in javascriptcalculate age dayjsjavascript calculate age from date of birth in months js born agenode js age countingcalculate age based on the year of birth using javascriptwrite a function that determines the given age that person is in javascripthow to calc age jsdate of birth node jsjavascript date of birth calculatorbitrthdate javascripthow to check age in javascriptjs get age from date stringjs age from dateage calculator from date of birth javascriptage mwthod jsjavascript calculate age from integerjs calculate age from datejavascript age in yearscheck age javascripthow to get a person 27s day of birth and convert it to name on jsdate js calculage ageget age with dayjsfind age from date of birth javascriptcalculate age by birth date javascriptcalculate age from dob html javascriptcalculating age from dob in javascriptjavascript to validate agejavascript birthday datejavascript to calculate user 27s age 2c based on dob in javascriptget age jshow to validate age using javascriptjavascript calculate someone 27s agenode js calculate agecalcualting age from date pf birth javascriptcalculating age from years inside array in javascriptcalculate age using date of birth javascriptconvert date of birth to age in javascripthow to find age by date of birth in javascriptcalculate age from date jscalculate age using date of birth in javascriptconvert date to age in javascriptbirthdate to age javascriptcheck age in javascriptjavascript 27s agecalculate age with month from date of birth in jscalculate age from string date of birth in javascripthow to get the age of given birth date in an object javascriptjavascript age calculatorbirthdate javascriptjavascript get ageget age javascriptjavascript count agehow to get your birthday in jsjs get agejavascript get birthdayjavascript calculate age dage calcxulator javascriptjavascript calc age from datecalculate age by birthday javascriptfind age jshow to code a check age function in javascripthow to get age from date of birth in javascriptformat age in age group in javascriptget date of birth javascriptconvert age to days from birthday javascriptcalculating age from date of birth in javascriptaccurate age calculator javascriptcalculate age from birthdate on jsfind age from date of birth jsbirth date via age in jshow to find age in days javascriptjs check for agehow to make an age calculator in javascriptjavascript calculate age by date of birthcalculate age jshow to check age jscalcage 2820 29 javascriptget age from date in javascriptjavascript calculate age in daysget age from ist javascriptage calculator by year jscalculate age function javasciptcalculate age javascriptcalculate age from date of birth dayjscheck age jshow to use date to calculate date of birth javascripthow to culculate age according to date of birth jsjs function to calculate agejavascript calculate afesimple age calculator in htmljs age calculatorage calculation javascriptjavascript register date of birth to ageget age from date of birthage calculator using javasscriptjavascript get age from dobage calculation javascript functionage calculator javascript getdate 28 29javascript function for age calculationdate to age and age to dob in jsexact age calculator javascriptcalculate age in javascript formjs calculate age from birthdatefind age javascriptmethod to calculate age from date of birth in javascriptcalculate age with javascriptcacluate age in javascriptnew date javascript agehow to calculate a person 27s age with javascriptcalculate age from date of birth using datepicker in jqueryage calculator js from date of birth textbocbrthday function javascriptnumber day determinate age on earth jshow to calculate age based on date of birth in javascriptjavascript birth yearage check javascripthow to calculate age javascripthow to return age year in number in jsjavascript how to calculate age by date of birthjs age functionget new age javascripthow to find age of person using javascriptjs ageget age from date of birth htmljavascript code to calculate age from date of birthhow to calculate age from date of birth in htmlcalculate your date of birth javascriptcalculate age formula javascriptdetect age from date jswrite a function calculate age that takes your birthday in the format dd 2fmm 2fyyyy and return your agehow to validate age in form using javascriptprogram to calculate age from date of birth in javascript calculate age from new date jshow to make a date of birth from javascriptfind age from date of birth in javascriptconvert year into age jqueryget date of birth in age javascriptcalculate date of birth from age in javascriptgetting age automatically when given date of birth javascripthow to determine the age and days in javascript to a given date of birthhow do i calculate someone 27s age based on a datetime type birthday 3f in jsget birth year from age in javascriptshow your age jsnode js age countingfind age bt date stringhow age calculate online by date of birth using javascriptfunction acceptintomovie 28age issupervised 29 javascriptwhat is the javascript code for an age calculator bot get the age from date of birth javascriptcalculate age from date jsget date of birth from age javascriptjavascript get exact age from datecalculate age acurate javascriptdate counting by age in javascript from inputage range calculation based on date of birth vuejsdate of birth using jshow to calculate age in javascriptcalc common age jsjavascript age calculator from date of birthjavascript function calculate age date birthcalculate age from date of birth node jsjs how to calculate ageage calculater jswork out birthday from current date reactjs date calculate agestore birth year in variable javascriptcalculate age from id number javascriptjavascript calculate age from birth datecalculate current age java scripthow to find age javascripthow to calculate your birthday using javascriptcalculate age given date in jsdate to age calculator in javascriptcalculate age from date javascriptget age from date of birth javascriptjs birth agecalculate age by date of birth and todays date using javascriptfunction to calculate age and days in javascripthow to get age from birth year in jshow to calculate a person 27s day of birth from date in javascriptjavascript get birthdate with minimum age javascript realtime calculate age from dateread a number in javascript and return age javascript get age from date of birthcalculating age using javascriptcalculate the age from date of birth in javascriptcalculate age from dob html javascript w3schoolsage find with date of birth jsuse javascript to get ageconvert age into date of birth jsage calculator javascriptcalculate age by date of birth in javascriptcalculate birthdate javascriptcalculate age from date of birth in nodejscalculate age javascript with birthdate and current datehow to use a user input date to calculate age in java scriptjs work out age from dobage calculate in jsget age by date of birth in java scripthow to know the age with the date of birth nodewrite a function in js that calculates the born dayjavascript get age from datejavascript calculating age from date of birthage calculator javascript w3schoolsage by date javascriptage javascripthow to get current age from date of birth javascriptage function in javascriptjavascript calculate birth dateget a person 27s age with two javascript datescalculate age function javascriptdate to age javascriptage and date of birth html javascriptage calculator html css javascriptjs maths for working out if date of birth is greater or less than an agehow to find age in express jsfinding out age javascriptage calculator logic in javascripthow to find someone 27s date of birth from date in javascriptjs get age from birth dateget age from date jscalc age in jsconvert age to days using form jsage calculation jscalculate age at certain year in javascriptjs get age from datescalculate age in years javascriptjavascript work out how old someone is based on their birthdayconvert date of birth to age with javascripthow to turn age to birth date in jshow to count age from date of birth in htmlsimple age calculator in jsget birth date from age jsget age according two date jscalculate age by birthdate jsfind age from date jsexpress js find agejs calculate age functionjavascript calculate age differenceage calculator in javascriptget age from dob javascriptenter date of birth for age calculate in javascript fromdisplay age jscalculate age with timestamp in jshow to calculate age from date of birth in javascriptstack overflow age jscalculate age function javascript w3schoolscalculate age with javacsript datehow to calculate birth year from age in javascriptjavascript age from datejs date to agecalculate age javascript html domhow to calculate age usog javascript date and timetime and date stamp to calculate aging javascriptjavascript ageage calculator from date of birth javascript precisecheck certain age javascriptjavascript to calculate age based on dobage calculator is jsjs calculater agehow to create age calculator in javascriptage calculation in html and javascriptclaculate age from birthdate in javascriptnew date age calculator jsage of java scriptfunction to calculate age from date of birth in javascriptget age in javascripthow to calculate the age in java scriptjavascript counting age from dateis there a function in javascript to calculate age in datevar age 3d 7bperson 7djavascript calculate age todays datehow get current age in reactage from birth date jscalculate age from birthdate jsjavascript to calculate age from date of birthhow to find age in javascriptjavascript calculate born datejavascript calculate age from date stringget age from current date javascriptage in javascriptjavascript to calculate user 27s age 2c based on dobcalculating age javascriptjavascript calculate date of birth how to calculate the age in javascriptget age in years jsage calculatorhow to check age validation in javascriptcalculate age of person in javascriptjavascript funtion to calculate age above 18javascript age calculatorshow birthdate in jscalculate age using date object jscalculate age javascript htmlhow to find age from date of birth timestamp in javascriptage calculator using javascriptget exact age from data jshow to count age by date of birth in vuejsangualr check minor age datehow to get age from date of birth using javascriptjavascript code to calculate age in yearsjavascript calculate age between two datesmethod to compute age from birth year jsjs calculate age from date in real timebirth year javascripthow to calculate age next birthday javascriptconvert age in years to age in days javascriptenter date of birth for automatic age calculate in javascript from fieldage calculator js calclate age in jsjavascript calculate age with valuesage method jsdetermine someons exact age with date object jsjavascript function to calculate age from date of birthcalculate date of birth from age javascriptjavascript code for displaying date birthdayhow to get the age of given birth date in javascripthow to calculate age in es6 javascriptjavacript age from datecalculate age in jshow to make program about age calculator in javascript js date of birthusing javascript to calculate age from database iso datejavascript calculate age given date stringjs date of birthage calculator using java scriptjavascript age calculator appcalculate exact age from date of birth javascripthow to find age from date of birth in jsjs input date of birth calcget exact age javascriptcalculate age from dob html javascriptw3schoolsget age according to date jsmariage age javascriptcalculate age js