<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: age code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Tue, 07 Oct 2008 18:57:07 GMT</pubDate>
    <description>DZone Snippets: age code</description>
    <item>
      <title>Calculate Age</title>
      <link>http://snippets.dzone.com/posts/show/1310</link>
      <description>With this function you can calculate the age of a person&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;echo "Age is: " . birthday ("1984-07-05");&lt;br /&gt;&lt;br /&gt;Result will be (23 Feb 2005) = "Age is: 20"&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;?php&lt;br /&gt;&lt;br /&gt;  //calculate years of age (input string: YYYY-MM-DD)&lt;br /&gt;  function birthday ($birthday){&lt;br /&gt;    list($year,$month,$day) = explode("-",$birthday);&lt;br /&gt;    $year_diff  = date("Y") - $year;&lt;br /&gt;    $month_diff = date("m") - $month;&lt;br /&gt;    $day_diff   = date("d") - $day;&lt;br /&gt;    if ($day_diff &lt; 0 || $month_diff &lt; 0)&lt;br /&gt;      $year_diff--;&lt;br /&gt;    return $year_diff;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;?&gt;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 28 Jan 2006 23:32:45 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1310</guid>
      <author>mjlintz ()</author>
    </item>
  </channel>
</rss>
