Are you new? Read the FAQ and catch up on!
524 views

Calculate an age

This functions calculates the age of someone, given its birth date or year:

PHP
  1. /**
  2.  * Gets the age of an individual
  3.  * @param int $timeStamp
  4.  * @return int
  5.  */
  6. function getAge($timeStamp) {
  7.     $seconds = time() - strtotime($timeStamp);
  8.     $year = 60 * 60 * 24 * 365;
  9.  
  10.     return floor($seconds / $year);
  11. }
  12.  

­

I found this function here.

Tags: PHP date/time

Embed: