プロフィールページの年齢を自動更新したい。
JSのコードを突っ込んで、誕生日と日付を比較して自動更新させるようにした。解決。

定期メンテナンスが必要な値は少ないほうが良いですね・・・
目次
コード
function calculateAge(birthDate) {
const today = new Date();
const birth = new Date(birthDate.substring(0, 4), birthDate.substring(4, 6) - 1, birthDate.substring(6, 8));
let age = today.getFullYear() - birth.getFullYear();
const m = today.getMonth() - birth.getMonth();
if (m < 0 || (m === 0 && today.getDate() < birth.getDate())) {
age--;
}
return age;
}
document.getElementById('age').textContent = calculateAge('19981221');
コメント