Re: subtracting dates...
| From: | Craig Roberts | Date: | Sat, 02 Aug 2003 19:52:06 +0000 |
| Subject: | Re: subtracting dates... | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-158050@lists.php.net to get a copy of this message | ||
Another idea (slightly simpler)...
how about using mktime(); to create a timestamp from your date info, and
subtract that from the current timestamp - leaving (i think) the person's
age in seconds...
Then just do some math...
hmm... is that really simpler? well it seemed it when i started typing
craig :)
"John Ryan" <celticfc@iol.ie> wrote in message
news:20030802193827.44969.qmail@pb1.pair.com...
> yeah, i was thinking that before i decided to post to the newsgroup. i
> thought there was some simple way of doing it and id be wasting my time.
> obviosuly not
>
>
> "Craig Roberts" <CraigRoberts@CJRobs.NeT> wrote in message
> news:20030802193634.40267.qmail@pb1.pair.com...
> > Try something along the lines of
> >
> > if($current_MM < $MM) {
> > $age = $calculatedage - 1;
> > }
> >
> > you'll also need to do something like this with the day of the month if
> the
> > user's bday is in the current month.
> > at least... i think that works out :$
> > Craig Roberts
> >
> >
> > "John Ryan" <celticfc@iol.ie> wrote in message
> > news:20030802192952.32960.qmail@pb1.pair.com...
> > > Hi,
> > >
> > > In mySQL, I store dates as YYYY-MM-DD, a standard DATE type. It stores
> > users
> > > date of births. I need to calculate in a PHP script, the users age
from
> > this
> > > DOB. I get a PHP date in the same format as the mySQL and subtract,
> which
> > > returns the year rounded off. ie, it doesnt matter if your birthdays
in
> > june
> > > of 1983 and the date is januray 2003, your age is still returned as
20,
> > when
> > > it should be 19.
> > >
> > > Does anyone know how can i get the right age?
> > >
> > >
> >
> >
>
>