[Typo3] Age Verification

Matthias Kall matthias.kall at web.de
Wed Aug 10 11:17:41 CEST 2005


Hi Frank,

here is a function to get a persons age in years:
(example from php.net)

function persons_age($year, $month, $day)
{
    $tmonth = date('n');
    $tday = date('j');
    $tyear = date('Y');
    $years = $tyear - $year;
    if ($tmonth <= $month)
    {
        if ($month == $tmonth)
        {
            if ($day > $tday)
                $years--;
        }
        else
            $years--;
    }
    return $years;
}

you might want to implement a function like this and call it in your if statement:

If ($this->persons_age($year, $month, $day) >= 13) {
...

Instead of $year, $month, $day you can also use the php date functions to get the parts 
out of your variable $dateOfBirthField

Greets

Matthias


-- 
_______________________________________
Matthias Kall
matthias.kall at web.de



More information about the TYPO3-english mailing list