note 48791 deleted from function.date by derick

From: Date: Sun, 15 Jan 2006 12:48:30 +0000
Subject: note 48791 deleted from function.date by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-101848@lists.php.net to get a copy of this message
Note Submitter: chris dot shepherd at gmail dot com ---- The previous post about calculating age using the date function... "chris dot shepherd at gmail dot com 27-Aug-2004 09:59 A nice way to calc age seeing that mktime only goes back until 1970 is to use the date function like this... " There is a line of code I entered incorrectly ($monthdiff <= 0 && $daydiff < 0) It should actually be (($monthdiff < 0) || ($monthdiff == 0 && $daydiff < 0)) The first example will be wrong when monthdiff is negative and daydiff is positive. For example current date is 01/06/2004 and dob is 03/02/1979. Whenever the monthdiff is negative we should always consider the condition true (we havent reached their bday yet) The original statement thinks the day matters when really the day only matters when we are in the month of our birth.

« previous php.notes (#101848) next »