WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Calculate age droplet
  • Print
Pages: [1]   Go Down

Author Topic: Calculate age droplet  (Read 6616 times)

Offline noname8

  • Posts: 151
Calculate age droplet
« on: January 27, 2012, 10:27:22 AM »
Just a simple droplet to calculate age in years (with decimal) and days :mrgreen:
Name
Code: [Select]
bdayDesc.

Code: [Select]
Calculate total age from birthdate years and days

code
Code: [Select]
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
Code: [Select]
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.

Logged

Offline KP

  • Posts: 66
  • Gender: Male
    • CREVIN
Re: Calculate age droplet
« Reply #1 on: July 25, 2013, 11:28:21 PM »
I get
Code: [Select]
This droplet has invalid PHP code.[/color] error.
Logged

Offline marmot

  • Posts: 1103
Re: Calculate age droplet
« Reply #2 on: July 25, 2013, 11:43:35 PM »
Hi,

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

regards
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Droplets & Snippets »
  • Calculate age droplet
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2