PHP Script: Birthday (how old are you?)
Last Update: 27.05.2008
Believe me! I was looking for such kind of script for years and never found one that actually worked! I even tried to program one myself 3 years ago, gave it up though because I ran into a problem with the leap-years (February 29th's). By programming the "about"-part of this site I was looking for a birthday-script again and this time I found one. Check it out!
<?php
/*
Calculate Age
With this function you can calculate the age of a person
Example:
echo "Age is: " . birthday ("1984-07-05");
Result will be (23 Feb 2005) = "Age is: 20"
calculate years of age (input string: YYYY-MM-DD)
*/
function birthday ($birthday)
{
list($year,$month,$day) = explode("-",$birthday);
$year_diff = date("Y") - $year;
$month_diff = date("m") - $month;
$day_diff = date("d") - $day;
if ($month_diff < 0) $year_diff--;
elseif (($month_diff==0) && ($day_diff < 0)) $year_diff--;
return $year_diff;
}
echo birthday("1985-07-25");
?>
Script found on webscripts.softpedia.com. Many thanks to script developer mjlintz.
AWS Android Ansible Apache Apple Atlassian BSD Backup Bash Bluecoat CMS Chef Cloud Coding Consul Containers CouchDB DB DNS Database Databases Docker ELK Elasticsearch Filebeat FreeBSD Galera Git GlusterFS Grafana Graphics HAProxy HTML Hacks Hardware Icinga Influx Internet Java KVM Kibana Kodi Kubernetes LVM LXC Linux Logstash Mac Macintosh Mail MariaDB Minio MongoDB Monitoring Multimedia MySQL NFS Nagios Network Nginx OSSEC OTRS Observability Office OpenSearch PGSQL PHP Perl Personal PostgreSQL Postgres PowerDNS Proxmox Proxy Python Rancher Rant Redis Roundcube SSL Samba Seafile Security Shell SmartOS Solaris Surveillance Systemd TLS Tomcat Ubuntu Unix VMWare VMware Varnish Virtualization Windows Wireless Wordpress Wyse ZFS Zoneminder