Advanced Age Script.
Posted: Fri Mar 04, 2005 1:08 pm
Hi guys, i have working for serval hours now, trying to create a age script.
and did it, i thought...
my problem is, that there is serval times every day where the script fails.
im born at nov 5th, 1980, at 7:15am.
this is what i got:
i've found out, that in the 7, 8, 9, 10th month, it puts +1 hour to the time, and in 3,4,5 (i think it was) it substracts an hour.
Andbody knows what's wrong, or even have a bulletproof age script??
Btw. I live in denmark, and GMC = +1.
feyd | please use
and did it, i thought...
my problem is, that there is serval times every day where the script fails.
im born at nov 5th, 1980, at 7:15am.
this is what i got:
Code: Select all
function show_age() {
setlocale (LC_ALL, 'da_DK');
$str_bday = "5/11/1980 7:15";
$ar = explode( ' ', $str_bday );
$dmy = explode( '/', $arї0] );
$hm = explode( ':', $arї1] );
$ydiff = 2037 - date( 'Y' );
$age = strtotime( "+$ydiff years" ) - mktime( $hmї0], $hmї1], 0, $dmyї1], $dmyї0], $dmyї2] + $ydiff );
$y = strftime( "%Y", $age ) - 1970;
$m = strftime( "%m", $age ) -1;
$d = strftime( "%d", $age ) -1;
$t = strftime( "%k", $age) -1;
$mins = strftime( "%M", $age);
$mins = str_replace("0", "", $mins);
if(!$mins) {
$m = "0";
}
$months = "month";
$days = "day";
$hours = "hour";
$minutes = "minut";
if($m != "1") {
$months = $months . "s";
}
if($d != "1") {
$days = $days . "s";
}
if($t != "1") {
$hours = $hours . "s";
}
if($mins != "1") {
$minutes = $minutes . "es";
}
$age = strftime( "$y years, $m $months, $d $days, $t $hours and $mins $minutes", $age );
return($age);
}Andbody knows what's wrong, or even have a bulletproof age script??
Btw. I live in denmark, and GMC = +1.
feyd | please use
Code: Select all
tags whileCode: Select all
is offline[/color]