AnimalnNote Infomation:
パートナーアニマルの健康を主治医との コミニケーションを通して管理する |
![]() |
vetssweb修正
メッセージ作成日:2015-10-07
表示期限日付:2015-10-07
ヘルスペットよりバグ確認あり
clntpetwrkset2.phpの修正
誕生日よりの年齢計算の修正変更
//旧ルーチン
$_SESSION['petbdayw']="2012-10-01";
$yy=substr($_SESSION['petbdayw'],0,4);
$mm=substr($_SESSION['petbdayw'],5,2);
$dd=substr($_SESSION['petbdayw'],8,2);
$ty = date("Y");
$tm = date("m");
$td = date("d");
$age = $ty - $yy;
echo $age."
";
if($tm * 100 + $td < substr($_SESSION['petbdayw'],5,2) * 100 + substr($_SESSION['petbdayw'],8,2)){
$age=$age-1;
}
if($tm==$mm){
if($td>$dd){
$age=$age+1;
$agem=0;
}else{
$agem=11;
}
}elseif($tm<$mm){
$agem=12-($mm-$tm);
}else{
$agem=$tm-$mm;
}
echo "age",$age."才".$agem."ヶ月
";
//新ルーチン
//年齢計算
$today=date('Y-m-d');
$bdayw=$_SESSION['petbdayw'];
$nengetu=substr($today,0,4)*12+substr($today,5,2)-substr($bdayw,0,4)*12-substr($bdayw,5,2);
$nen=floor($nengetu/12);
if(substr($today,5,2)!=substr($bdayw,5,2)){
//当月が誕生日月より大きい
if (substr($today,8,2)>=substr($bdayw,8,2)){
//本日が誕生日の日が当日または大きい
$getu=$nengetu-($nen*12);
}else{
//本日が誕生日の日より小さい
$getu=$nengetu-($nen*12)-1;
}
$pet_age=$nen."才".$getu."ヶ月";
}else{
//当月が誕生日月と同じか小さい
if (substr($today,8,2)>=substr($bdayw,8,2)){
//本日が誕生日の日が当日または大きい
$getu=$nengetu-($nen*12);
}else{
//本日が誕生日の日より小さい
$getu=11;
$nen=$nen-1;
}
$pet_age=$nen."才".$getu."ヶ月";
}
echo $nen."才".$getu."ヶ月";