Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Books
Sample Chapters
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

Get age by date

This function example returns the age of a person by theyre date of birth

<?php

/**************************************************
*
* int getAgeByDate(int $mm, int $dd, int $yyyy)
*
**************************************************
*
* Returns age of person by the person's birth date
*
**************************************************
*
* Parameters:
* $mm - Month of birth
* $dd - Day of birth
* $yyyy - Year of birth
*
**************************************************
*
* Return value
* Age of person
*
**************************************************
*
* Author: Matthew R. Villa <matt@1-percent.com>
* Last modified: 10.01.2000
*
* Copyright (c) 2000 1-Percent.com
*
*/

function getAgeByDate($iMonth, $iDay, $iYear) {
$iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear);
$iDays = $iTimeStamp / 86400;
$iYears = floor($iDays / 365.25);
return $iYears;

}

?>


Usage


echo getAgeByDate(04, 17, 1980);

The result will display "22"