2017 © Pedro Peláez
 

helper calculateage

Calculate age by date of birth

image

calculateage/calculateage

Calculate age by date of birth

  • Friday, May 6, 2016
  • by farhanwazir
  • Repository
  • 2 Watchers
  • 5 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

# CalculateAge

Calculate age in php by age calculator function., (*1)

Usage

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)

Possible Formats

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)

The Versions

06/05 2016

dev-master

9999999-dev https://github.com/farhanwazir/CalculateAge

Calculate age by date of birth

  Sources   Download

MIT

The Requires

  • php >=4.2.0

 

calculator age dob age calculator date of birth