Answers for "calculate age from date of birth in javascript hijri"

1

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;
}
Posted by: Guest on May-25-2020
2

calculate age js

const calAge = (date) => new Date(Date.now() - new Date(date).getTime()).getFullYear() - 1970;
Posted by: Guest on July-17-2021

Code answers related to "calculate age from date of birth in javascript hijri"

Code answers related to "Javascript"

Browse Popular Code Answers by Language