|
 |
|
อยากทราบการคำนวณอายุ - ป้อนข้อมูลของวันเกิด แล้วให้ อายุขึ้นโดยอัตโนมัติ |
|
 |
|
|
 |
 |
|
|
 |
 |
 |
 |
Date :
2009-03-20 07:38:56 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอาไปลองดูนะครับ
<form id="form1" name="form1" method="post" action="age.php">
<p>
<input name="birthday" type="text" size="40"/>
<input type="hidden" name="t" value="1"/>
<input type="submit" name="Submit" value="Submit" />
</p>
<p>
<input name="textfield2" type="text" value="<?php if ($t==1) echo age("$birthday") ;?>" size="40"/>
<?
function age($birthday) {
list($day,$month,$year) = explode("-", $birthday);
$datedeb=mktime(0,0,0,$month,$day,$year);
$datefin=time();
$aad=date("Y",$datedeb);
$mmd=date("m",$datedeb);
$jjd=date("d",$datedeb);
$aaf=date("Y",$datefin);
$mmf=date("m",$datefin);
$jjf=date("d",$datefin);
$nbj=array(0,31,28,31,30,31,30,31,31,30,31,30,31);
if(($aaf % 4)==0){$nbj[2]=29;}
if((($aaf % 100)==0)&(($aaf % 400)!=0)){$nbj[2]=28;}
if($jjf<$jjd){$jjf=$jjf+$nbj[(int)$mmf];$mmf=$mmf-1;}
if($mmf<$mmd){$mmf=$mmf+12;$aaf=$aaf-1;}
return "อายุ ".($aaf-$aad)." ปี ".($mmf-$mmd)." เดือน ".($jjf-$jjd)." วัน";
}
?>
</p>
</form>
|
 |
 |
 |
 |
Date :
2009-03-20 09:16:00 |
By :
นักเรียน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
     
|
 |
 |
 |
 |
Date :
2009-06-04 17:11:17 |
By :
ปุณณกันต์ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 00
|