Jump to content
php.lv forumi

Iegut vecumu no datuma


Mikijs

Recommended Posts

tatad dabuuuju pats ja nu kadam vajag

	function getAge($y,$m,$d){
		$year_diff = date("Y") - ($y);
		$month_diff = date("m") - ($m);
		$day_diff = date("d") - ($d);
		if ($month_diff < 0) $year_diff--;
		elseif ($month_diff == 0 && $day_diff < 0) $year_diff--;
		return $year_diff;
}

Link to comment
Share on other sites

<?php

 

$dob = '1984-12-30';

 

$age = date('Y') - date('Y', strtotime($dob));

if (date('md') < date('md', strtotime($dob))) {

$age--;

}

 

echo $age;

?>

Link to comment
Share on other sites

×
×
  • Create New...