Jump to content

Recommended Posts

Posted

Daca vreti sa determinati varsta unei persoane, folosindu-va de niste date de forma: zi/luna/an sau an/zi/luna, etc, atunci aveti mai jos un mic script PHP, care va face acest lucru.

<?php
function make_age($var, $type) {
$date = explode ( "/", $type );
$number = explode ( "/", $var );
$aaa = count ( $number );
for($i = 0; $i < $aaa; $i ++) {
 if ($date [$i] == "d") {
  if ($number [$i] > date ( "d" )) {
   $month = $month + 1;
  } else {
   $month = $month - 1;
  }
 }
 if ($date [$i] == "y") {
  $year = date ( "Y" ) - $number [$i] + $year;
 }
 if ($date [$i] == "m") {
  if (($number [$i] + $month) < date ( "m" )) {
  } else {
   $year = $year - 1;
  }
 }
}
return $year;
}
?>
[/code]

[b]$var[/b] = este data in format zi/luna/an sau intr-un format asemanator;

[b]$type[/b] = tipul datelor primite in primul paramentru.(se foloseste d pentru zi, y=an, m=luna). De exemplu se poate trece la type d/y/m ceea ce arata ca datele trimise in var sunt sub forma zi/an/luna

Succes :pct2:

Te-ai inregistrat? Ne-ar placea sa te prezinti.

Cum pot sustine forumul?
Cumpara de la eMag folosind acest link.
--------------------
oG2BN9d.gifse1WdXd.gifQG6MtmI.gifRHYjDzD.gifG5p1wui.gif

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.