dev-master
9999999-dev https://github.com/farhanwazir/CalculateAgeCalculate age by date of birth
MIT
The Requires
- php >=4.2.0
by Farhan Wazir
calculator age dob age calculator date of birth
Calculate age by date of birth
Calculate age in php by age calculator function., (*1)
Just call function ageCalculator(Date, format), Date parameter must be DateTime and possible formats are mentioned below., (*2)
Examples;, (*3)
ageCalculator( new DateTime('1982-07-24') ); //33 years, 1 month and 9 days, (*4)
If you are using laravel then it is more easy with Carbon like ageCalculator( new Carbon('1982-07-24') );, (*5)
ageCalculator( new DateTime('1982-07-24'), 'd' ); //1201, (*6)
ageCalculator( new DateTime('1982-07-24'), 'D' ); //1201 days, (*7)
ageCalculator( new DateTime('1982-07-24'), '%m' ); //1, (*8)
ageCalculator( new DateTime('1982-07-24'), '%M' ); //1 month, (*9)
ageCalculator( new DateTime('1982-07-24'), '%y y, %m m and %d days old' ); //33 y, 1 m and 9 days old, (*10)
ageCalculator( new DateTime('1982-07-24'), '%Y, %M and %D old' ); //33 years, 1 month and 9 days old, (*11)
d -- It returns total number of days in numeric., (*12)
m -- It returns total number of months in numeric., (*13)
y -- It returns total number of years in numeric., (*14)
D -- It returns in string with total number of days like 400 days or 1 day., (*15)
M -- It returns in string with total number of months like 397 months or 1 month., (*16)
Y -- It returns in string with total number of years like 33 years or 1 year, (*17)
GET RETURN WITH CUSTOM FORMAT, THIS WILL RETURN FROM '33 years 1 month 19 days'. FOR EXAMPLE, IF YOU WANT NUMBER OF DAYS THEN IT WILL ONLY GET NUMBER OF DAYS FROM MENTIONED EXAMPLE INSTEAD TOTAL NUMBER OF DAYS COUNT FROM DAY YOU BORN., (*18)
%d -- It returns number of days but not same as above d. It returns number of days from 33 years 1 month 19 days., (*19)
%m -- It returns number of months, maximum month is 11., (*20)
%y -- It returns number of years, how old you are., (*21)
%D -- It returns with string, don't worry about singular and plural., (*22)
%M -- It returns with string., (*23)
%Y -- It returns with string., (*24)
Calculate age by date of birth
MIT
calculator age dob age calculator date of birth