note 55637 added to function.date

From: Date: Tue, 09 Aug 2005 13:30:24 +0000
Subject: note 55637 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-93312@lists.php.net to get a copy of this message
same code as djneoform at gmail dot com, but added the split function to make things a little simpler for getting age from birthdate <? function persons_age($BirthDate) { list($year, $month, $day) = split('[-.]', $BirthDate); $tmonth = date('n'); $tday = date('j'); $tyear = date('Y'); $years = $tyear - $year; if ($tmonth <= $month) { if ($month == $tmonth) { if ($day > $tday) $years--; } else $years--; } echo $years; } persons_age('1978-12-06') ?> ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55637 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55637&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55637&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#93312) next »