I need a script that can change
$DD
$MM
$YYYY
as the DOB to there current age.
Thanks
Daniel
$DD
$MM
$YYYY
as the DOB to there current age.
Thanks
Daniel
| Code: |
|
<?php $MM = 1; $DD= 1; $YYYY = 1988; $bDay = mktime ( 0, 0, 0, $MM, $DD, $YYYY ); $cTime = time (); $age = $cTime-$bDay; $yr = floor ( $age/(60*60*24*356.25) ); print "You are $yr years old"; ?> |
| Code: |
| <?php
function calculate_age($y, $m, $d) { $guess_age = date('Y') - $y; $guess_time = mktime(0, 0, 0, $m, $d, $y + $guess_age); if ($guess_time > time()) { $age = $guess_age - 1; } else { $age = $guess_age; } return $age; } $YYYY = 2002; $MM = 1; $DD = 28; $age = calculate_age($YYYY, $MM, $DD); echo "You are $age years old.<br>\n"; ?> |
| Code: |
| $birthday = "01-17-1988";
$var = explode("-", $birthday); |
| duckling wrote: |
|
then, you can use: $var["0"] as day, $var["1"] as month, $var["2"] as year |