note 67987 deleted from function.date by bobby

From: Date: Thu, 07 Sep 2006 17:56:04 +0000
Subject: note 67987 deleted from function.date by bobby
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116853@lists.php.net to get a copy of this message
Note Submitter: Aristia ---- I wrote a small function for calculating birthdays. The days count doesn't seem accurate but the years and months are correct. It seems to be rough around the edges but it works for me :) function elapsed($year, $month, $day) { $bdaystamp = mktime(0,0,0, $month, $day, $year); $today = date("U"); $elapsed = $today - $bdaystamp; $years_remainder = $elapsed%31536000; $rawyears = $elapsed-$years_remainder; $years = $rawyears/31536000; $months_remainder=$years_remainder%2628000; $rawmonths = $years_remainder-$months_remainder; $months = $rawmonths/2628000; $days_remainder=$months_remainder%86400; $rawdays = $months_remainder-$days_remainder; $days = $rawdays/86400; $yearword = "Years"; $monthword = "Months"; $daysword = "Days"; $age= $years.' '.$yearword.' '.$months.' '.$monthword.' '.$days.' '.$daysword.''; return $age; } $age=elapsed("1978", "01", "18");

« previous php.notes (#116853) next »