0
私は年齢を計算しますが、私はこの1つ上のいくつかの変更を必要とするコードを持っている:計算年齢と月
<?php
//date in mm/dd/yyyy format; or it can be in other formats as well
$birthDate = $tk_image_geboortedag ."-". $tk_image_geboortemaand ."-". $tk_image_geboortejaar;
//explode the date to get month, day and year
$birthDate = explode("-", $birthDate);
//get age from date or birthdate
$age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md")
? ((date("Y") - $birthDate[2]) - 1)
: (date("Y") - $birthDate[2]));
echo "Huidige leeftijd: " . $age;
?>
今では返しますHuidigeはleeftijd:19(それは計算何でも)。
必要は何ですか。年齢が2歳未満の場合は、月額を表示する必要があります。したがって、生年月日が09-11-2016であれば、12ヶ月を表示しなければならず、月の数が23を上回る場合は年齢を表示します。
誰かがこれを手伝ってくれますか?
よろしく、 ロバート
'$ tk_image_geboortedag"ではなく、 'explode'を使う理由は - "です。 $ tk_image_geboortemaand。 " - " $ tk_image_geboortejaar; 'ヴァルス?ただ注文を変更してください... – HtmHell
あなたの答えをありがとう、完璧に説明した:)私はただ一つ変更した、私はif($ difference-> m <24){if($ difference-> y <2){。したがって、yの数が2以下の場合はmを表示します。それとも私は何かが恋しい? – n00bly
@ n00blyいいえ、彼らは同じことです。同じしきい値の同じ値をチェックするさまざまな方法。あなたのお手伝いをしてうれしいです: – Martin