Mikijs Posted January 26, 2009 Report Share 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 Link to comment Share on other sites More sharing options...
Maris-S Posted January 26, 2009 Report Share Posted January 26, 2009 Apskaties mysql date and time funkcijas, gan jau ka varēs no viņām ko salikt kopā. Link to comment Share on other sites More sharing options...
Mikijs Posted January 26, 2009 Author Report Share 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] Link to comment Share on other sites More sharing options...
Mikijs Posted January 26, 2009 Author Report Share 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; } Link to comment Share on other sites More sharing options...
marcis Posted January 26, 2009 Report Share Posted January 26, 2009 $vecums=floor((time()-strtotime($dzimsanas_diena))/(60*60*24*365.2425)); Link to comment Share on other sites More sharing options...
blackhalt Posted January 26, 2009 Report Share 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; ?> Link to comment Share on other sites More sharing options...
Recommended Posts