note 71925 added to ref.datetime
| From: | slash at mauricien dot org | Date: | Fri, 22 Dec 2006 21:06:08 +0000 |
| Subject: | note 71925 added to ref.datetime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120868@lists.php.net to get a copy of this message | ||
The post below has been edited saying there is a bug line 12 and 13 and proposition a solution. I
think there was no
bug in the original post.
menaurus at gmx dot de
16-Jul-2003 01:37
The argument has to be in the standard mysql format (y-m-d)...
function age($date) {
if (!$date) return false;
$year=0+substr($date,0,4);
$month=0+substr($date,5,2);
$day=0+substr($date,8,2);
$t=0;
$d=date("d");
$m=date("m");
$y=date("Y");
$age=$y-$year;
if ($m<$month) $t=-1;
else if ($m==$month) if ($d<$day) $t=-1;
return ($age+$t);
}
this funktion has got a little bug:
On Line 12 and 13...
Bugfix:
12 if ($month<$m) $t=-1;
13 else if ($m==$month AND $day<$d) $t=-1;
----
Server IP: 217.13.201.10
Probable Submitter: 87.178.219.2
----
Manual Page -- http://www.php.net/manual/en/ref.datetime.php
Edit -- https://master.php.net/note/edit/71925
Del: integrated -- https://master.php.net/note/delete/71925/integrated
Del: useless -- https://master.php.net/note/delete/71925/useless
Del: bad code -- https://master.php.net/note/delete/71925/bad+code
Del: spam -- https://master.php.net/note/delete/71925/spam
Del: non-english -- https://master.php.net/note/delete/71925/non-english
Del: in docs -- https://master.php.net/note/delete/71925/in+docs
Del: other reasons-- https://master.php.net/note/delete/71925
Reject -- https://master.php.net/note/reject/71925
Search -- https://master.php.net/manage/user-notes.php