showing results for - "javascript get age"
Loren
25 Jan 2020
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}
Alessia
23 Feb 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!");
Angela
09 Jun 2016
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
queries leading to this page
calculate age by date of birth javascriptjavascript get mt age find age jshow to get your birthday in jses6 calculate ageget age from date of birthdate of birth how to generate age jsjs age from datemethod to calculate age from date of birth in javascriptcalculate age in jshow to find age from date of birth in jsjs calculate age from date of birthcalculate age from given date of birth jsfind age from date of birth in javascripthow age calculate online by date of birth using javascriptcalculating age from date of birth in javascriptcalculate age based on date of birth in javascriptcompute age from date string javascriptcalculate age from date of birth in node jsjavascript date of birth to ageget your age using dates jsage calculator jsjs function to calculate agecalculate age using date of birth in javascriptcalculate age javascript with birthdate and current datehow to find someone 27s date of birth from date in javascriptjavascript calculate age in yearsage calculation on age select javascriptjs calculate age functioncalculate age at certain year in javascriptjs how to calculate agefunction to check age in javascript javascript get birthdate with minimum age javascript calc agecalculate age with timestamp in jscalculate age from id number javascriptcalculate age from date of birth in jsconvert age in years to age in days javascriptget age from current date javascripthow can i show my birth days in javascriptjs date to agefunction to calculate age from date of birth in javascriptjavascript birthday datejavascript get age categoryconvert year into age jquerycount age javascriptfunction acceptintomovie 28age issupervised 29 javascriptformat age in age group in javascripthow to add age to a birthdate jshow to find age from date of birth timestamp in javascriptget age by string value in javascriptget age from year jsdisplay name according to age in javascriptcalculate age from dob jscalculate age from date of birth from form javascriptget date of birth from age javascriptjavascript date get agejavascript age in yearshow to get the age with date of birth in javascriptcalculate age given date in jsage method jsjavascript calculate age by date of birthfunction to calculate age in javascriptcalculate age using javascriptjavacript age from datecalculate age jsjavascript calculate age based on date of birthget birth date from age jshow to get current age from date of birth javascriptjavascript get age by birth datedate to age and age to dob in jsget age from now and birth date javascriptjavascript date to agecalculate date of birth from age in javascriptjavascript age calculationjavascript calculate born datefind age in years in jsjavascript 27s ageage in javascriptjavascript compute ageage to day in jscalculate age from full date of birth jsfind age javascriptcalculate age from date of birth in javascript using calendarage calculate in javascriptwrite a function in js that calculates the born dayhow can i calculate the age of the person after giving his 2fher date of birth in input using javascript programcalculate age using form jsdate of birth using jsjavascript display current ageget age methd javascriptnode js age countingcalculate age from birthdate jscalculate age with todays age node jscalculate exact age from date of birth javascriptcompare value to the date 28 29 to obtain age javascriptjs calc agejavascript age counterprogram to calculate age from date of birth in javascript get age from date of birth jsage calculate using jscalculating age from dob in javascriptjavascript age calculator from date of birthcheck age javascripthow to check age with date of birth in javascriptshow birthdate in jscalculate date of birth from age javascriptjavascript code to calculate age from date of birthcalculate age javascriptjavascript function to calculate age from date of birthhow to get the age of given birth date in an object javascripthow to find age javascriptcalculate birthdate from age jshow to return age year in number in jsjavascript age from birthdatecreate 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 javascript calculate age from date of birth in months javascript calculate age in years from date of birthcalculate age in javascriptcalculate age from date javascriptjavascript calculate age from yearjs date of birthdate to age javascriptget age in javascriptjavascript register date of birth to agedate born to now jssave age in javascriptget the age from date of birth javascriptjavascript calculate birth datecalculate current age java scriptjs calculate age from birthdatefind age in jsage from date javascriptcalculate date of birth from age in javascript and return only valuejavascript 27 27 3e function to calculate age from date of birth entered in a datepickercalculate age by birth date javascriptcalculate age by date of birth in javascripthow to find age by date of birth in javascripthow to check age with date of birth with out using javascript predefine functionshow to calculate a person 27s age with javascriptbirthday to age javascriptjavascript calculate age from birth datecheck age number in javascript function htmlget age from date in javascriptget date of birth in age javascriptconvert date of birth to age in javascripthow to calculate age from date of birth in javascriptcalculating age using javascriptage javascriptjavascript calculate age using arrow functionhow to get birth year from age javascriptage calculator javascriptcalc age in jsjavascript funtion to calculate age above 18js birth agemethod to compute age from birth year jsget year with a birth date to methods javascriptget age js with mouthshow i find the age jsfrom date to age function javascripthow to calculate age from date parse valuescalcage 2820 29 javascriptjavascript age ratinghow to get age from birth year in jscalculate age javascript date birthjs know how old someone isjavascript function calculate age date birthjs get agejavascript birth yearhow to make an age calculator in javascriptjavascript date of birth calculatorjavascript get age from date of birthdate to age jsjs born ageget age according two date jsget age from date of birth javascriptjs date calculate agehow to find age in days javascriptcalculate age using date jshow to calc age jscalculate age based on date of birth javascriptget age from dob jscalculate age given a birthdate in javascriptcheck certain age javascripthow to calculate the age from date of birth in javascriptget age from dob javascripthow to get your age using javascriptjavascript calculate age in years 2c months daysjavascript get age from dobcalculate age from date of birth 2c jqueryage 2b 2b javascripthow to get age from date of birth in jshow to get age in javascriptjavascript to calculate age from date of birthhow to calculate birth year from age in javascriptjavascript current agehow to calculate age based on date of birth in javascriptreturn age from date jscalculate age by birthday javascripthow to calculate age in javascriptinput your dob 28date 29 through prompt for example date is 2224 22js calculate ageage calculator in javascripthow can i calculate persons age in javascript by date of birthage mwthod jscalculating age javascriptjavascript calculate afeget new age javascriptjs calculate age by dateget date of birth from user html jsget age by date of birth in java scriptcalculate age from date of birth using datepicker in jquerycalculate age from date of birth nodejshow to determine the age and days in javascript to a given date of birthbirthdate to age javascripthow to get a person 27s day of birth and convert it to name on jsget age with dayjsfind age from date jsdetermine someons exact age with date object jsjavascript calculate someone 27s agejquery get age from date of birthbirth date via age in jscalculate age from new date jscalculate date of birth javascriptjavascript realtime calculate age from dateage from date function javascriptcalculate age from date of birth javascriptbirthdate from age in jsstore birth year in variable javascriptcalculate age in days using date of birth in javascripthow to get the age of given birth date in javascriptcalculate age using date of birth javascriptcalculate age from date entered in form javascriptjavascript calculate age from datejs get age from datesuse javascript to calculate age from date of birth and age must be between 8 and 12 inclusivehow to calculate age using javascriptjavascript calculate someones ageage calculat birthdate jshow to turn age to birth date in jsdate of birth node jscalculate age in years javascriptjavascript get age from datejs age functionjs calculate age from date stringnode js calculate agecalc common age jsjavascript get birthdaycompute age javascriptget age show date of birth jsjavascript ageconvert date to age javascriptjs how to calculate your ageage calculation formula in javascripthow to calculate exact age in javascriptcalculate age with month from date of birth in jsyear calculator for age code in javascriptcheck age number in javascript functionfind age from date of birth javascripthow to calculate age from date of birth jscalculate age function javascriptcalculate age from year of birth in javascriptuse javascript to get agehow to make a date of birth from javascripthow to get age from date of birth using javascriptjs get age from birth datedob jshow to calculate the age in javascriptage from birth date jsnew date javascript agejavascript work out how old someone is based on their birthdayjs calculater agehow to determine age by dateof birth javascriptis there a function in javascript to calculate age in dateget age javascriptjavascript get the age from datecalculate age from date of birthage calculation from date jswrite a function that take birth date and returns age in years 2c months and days jscalculate age from birthdate javascriptavascript calculate age by date of birthhow to calculate age next birthday javascripthow to find age in javascriptcalculate age with date of birth javascript js date of birthcalculate age based on date of birth using javascriptcalculate age from days jshow to calculate current age from date of birth in javascript only yearscalculating age in javascript through date functionage calculator js from date of birth textbochow to count age from date of birth in javascriptshow your age jscalculate for age in jscalculate your date of birth javascriptcalculate age with jsget age from date javascriptjavascript calculating age from date of birthhow do i calculate someone 27s age based on a datetime type birthday 3f in jstime and date stamp to calculate aging javascriptage calculate in jsget birth year from age in javascriptage find with date of birth jshow to find age today in javascriptjavascript function to display ageget age from date jsnumber day determinate age on earth jsget your age javascriptprogramme js calculate agejavascript calculate age from date of birthcalculate age from date of birth node jsjavascript to calculate age based on dobages based on dates vuejsread a number in javascript and return age calculate age from date in javascriptjs work out age from dobbitrthdate javascriptjavascript code to calculate age in yearscalculate age from date of birth in javascript hijrihow to code a check age function in javascriptjavascript to calculate user 27s age 2c based on dobget years by age jsjavascript counting age from datecalculate exact age in javascriptjs calculate age from date in real timejavascript work out age from date of birthget year of birth from age javascriptdate of birth javascripthow to get birth year from age in javascriptfind out age from date of birth in javascriptjs calculate age from datehow to find age of person using javascriptstack overflow age jsjs date from birthfunction that get age in javascripthow to get year from dob in javascriptcalculate age by date of birth and todays date using javascriptjavascript count agejavascript get agecompute age with birthdate javascriptcalculate age from date of birth in javascriptjavascript calculate date of birth age function in javascriptjavascript calculate age from integerjavascript find age from birthdatejs dob to yearsage and date of birth html javascripthow to check age in javascripthow to get age from date of birth javascriptcalculate the age from date of birth in javascriptage calculate jsget age dayjsbrthday function javascriptjavascript age from date of birthget age javascriptjavascript get exact age from datedetect age from date jscalculate age from dob html javascriptjavascript calculate age from birthdatehow to calculate age from date of birth javascriptbirthdate javascriptcalculate age by birthdate jshow to count age by date of birth in vuejs site 3astackoverflow comget age in years jsjs get age from date stringbirth year javascriptcalculate age from dob in javascriptage calculation using date of birth in javascripthow to calculate your birthday using javascripthow to calculate age javascriptget exact age javascriptjavascript get current agehow to count age by date of birth in vuejsvar age 3d 7bperson 7djavascript function take birthdate and return age age calculation in javascriptjavascript function to calculate age from date of birth entered in a datepickerage of java scriptcalculate age from date jscalculate age by date of birth javascripjs check date is certain agejs input date of birth calcwrite a function calculate age that takes your birthday in the format dd 2fmm 2fyyyy and return your agenode js age countinghow to calculate age in days in javascript using returndate age calculator javascriptjs check for agehow to know the age with the date of birth nodeclacualting age in jsjs get age from dateangualr check minor age dateconvert date of birth to age with javascriptconvert age to days from birthday javascriptconvert age into date of birth jsjavascript to calculate user 27s age 2c based on dob in javascriptjavascript calculate age todays datejavascript age difference validationcalculate age from date of birth jswork out birthday from current date reactjavascript date of birthcheck age jsjavascript age functionmariage age javascriptcalculate age formula javascriptfind date of birth from age using javascriptjs birthday to ageage calculator from date of birth javascripthow to use date to calculate date of birth javascriptfind the age in javascriptget date of birth javascriptconvert date to age in javascriptsimple age calculator in jscalculate age from birthdate on jsconvert age to days using form jshow to culculate age according to date of birth jsjs according to bday ageclaculate age from birthdate in javascriptjavascript calculate age on next birthdayautomatically calculate age from date of birth javascriptjavascript get age from birthdateget the age of a person from date javascriptage range calculation based on date of birth vuejshow to get age from date of birth in javascriptjavascript age of person based on birth dateget age jsjavascript age from datehow to get the age of given birth date in javascript 22get current age by birthday jshow to calculate a person 27s day of birth from date in javascripthow t o calculate age from current date in javascriptto convert the age of the person into equivalent days javascriptjavascript html get agecalculate age function javasciptyear of birthday calculator javascriptcalculate age using date object jsusing javascript to calculate age from database iso dateage calculation jsjavascript calculate agehow to print age date of birth in javascriptjs convert date to agefind age bt date stringjs get age from birthdatefrom age to date of birth javascriptdate of birth calculator javascriptcalculate age from date of birth dayjscheck age based on date of birth in javascriptcalculate birthdate javascriptcalculate age from date jscalculate dob from age in javascriptage calculation in jshow get current age in reactcalculate age acurate javascriptcalculate age today in dayjshow to calculate age in jscalculate age from date of birth in nodejscheck specific age based on day jshow to calculate age from todays date js functioncheck age in javascripthow to check age jsget age according to date jsgetting age automatically when given date of birth javascriptcalculate age from string date of birth in javascriptjavascript function to calculate age in yearget age with day jsjavascript calculate age from date stringjquery calculate date birth agetakes the age in years and returns the age in days javascriptdate to age calculator in javascriptget exact age from data jsget a person 27s age with two javascript datesjavascript get age