Calculate age droplet

marmot

Hi,

Quote from: crevinamd on July 25, 2013, 11:28:21 PM
I get This droplet has invalid PHP code.[/color] error.
this is because of "ENG" in line 12, just delete it.

regards

KP

I get This droplet has invalid PHP code.[/color] error.

noname8

Just a simple droplet to calculate age in years (with decimal) and days :mrgreen:
Name
bday
Desc.

Calculate total age from birthdate years and days


code
global $MESSAGE;
$output_value ="";
$d=trim($d);
$datenow=date("Y-m-d");
$diff=strtotime($datenow)-strtotime($d);
if($diff <0)$diff=$diff * -1; //no negative values
$days=floor(($diff)/86400);
$years=round(($diff /31536000), 2);

//DEBUG
//$output_value="$datenow $d Age is $years years. That's $days days";
ENG $output_value="Age is $years years. That's $days days";

return $output_value;



comment
Use this with [[bday?d=1950-12-31]]
You can add this to any place, even in the title of a link or alt text of an image. Also future day possible.