Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get age

function getAge(dateString) 
{
    var today = new Date();
    var birthDate = new Date(dateString);
    var age = today.getFullYear() - birthDate.getFullYear();
    var m = today.getMonth() - birthDate.getMonth();
    if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) 
    {
        age--;
    }
    return age;
}
Comment

javascript work out age from date of birth

// To calculate age:
var year_born = prompt("Please enter your date of birth:", "Type here");
var d = new Date();
var n = d.getFullYear();
function getAge(birthYear){
	var currentDate = new Date();
    var currentYear = currentDate.getFullYear();
    age = currentYear - birthYear;
    return age;
}
calculatedAge = getAge(year_born);
alert("Hello, " + "you are " + calculatedAge + " years old!");
Comment

PREVIOUS NEXT
Code Example
Javascript :: gatsby js quick start 
Javascript :: Disemvowel Trolls 
Javascript :: link change page react 
Javascript :: phaser place on part of circle 
Javascript :: phaser rotate around 
Javascript :: phaser animation repeat event 
Javascript :: phaser muy bridge 
Javascript :: phaser stagger play 1 
Javascript :: iterate cy.get(') elements 
Javascript :: toast plugin 
Javascript :: scan token deploy js 
Javascript :: node transitions 
Javascript :: Call this API in order to fetch the user data. API: https://jsonplaceholder.typicode.com/users. 
Javascript :: iterate over array of html elements 
Javascript :: rpirvate router react 
Javascript :: jquery selectors 
Javascript :: TypeError: expressValidator is not a function 
Javascript :: javascript break with while Loop 
Javascript :: what is slot in vue.js 
Javascript :: sequelize update 
Javascript :: javascript add onclick to multiple elements 
Javascript :: react create context 
Javascript :: javascript output a message into console 
Javascript :: how to download json object that come from backend in react 
Javascript :: how to map over arrays vuejs 
Javascript :: .unshift 
Javascript :: determine location of ip address nodejs 
Javascript :: discord message reply 
Javascript :: es6 hashset 
Javascript :: puppeter loop 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =