Mikijs Posted January 26, 2009 Report Posted January 26, 2009 (edited) Sveiki, Kā lai no padotajiem datiem (Gads, Mēnesis, Diena) iegūstu lietotāja vecumu ? Edited January 26, 2009 by Mikijs
Maris-S Posted January 26, 2009 Report Posted January 26, 2009 Apskaties mysql date and time funkcijas, gan jau ka varēs no viņām ko salikt kopā.
Mikijs Posted January 26, 2009 Author Report Posted January 26, 2009 vairaak interese php variants, jo dati nenak no SQL bet gan no lietotaja padota POST masiva. $bd[year] $bd[day] $bd[month]
Mikijs Posted January 26, 2009 Author Report Posted January 26, 2009 tatad dabuuuju pats ja nu kadam vajag function getAge($y,$m,$d){ $year_diff = date("Y") - ($y); $month_diff = date("m") - ($m); $day_diff = date("d") - ($d); if ($month_diff < 0) $year_diff--; elseif ($month_diff == 0 && $day_diff < 0) $year_diff--; return $year_diff; }
marcis Posted January 26, 2009 Report Posted January 26, 2009 $vecums=floor((time()-strtotime($dzimsanas_diena))/(60*60*24*365.2425));
blackhalt Posted January 26, 2009 Report Posted January 26, 2009 <?php $dob = '1984-12-30'; $age = date('Y') - date('Y', strtotime($dob)); if (date('md') < date('md', strtotime($dob))) { $age--; } echo $age; ?>
Recommended Posts