note 48791 added to function.date

From: Date: Fri, 07 Jan 2005 05:04:59 +0000
Subject: note 48791 added to function.date
Groups: php.notes 
Request: Send a blank email to php-notes+get-82879@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.date.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48791 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48791&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48791&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#82879) next »