This code computes the difference between dates:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method="post" action="">
<input type="DateTime" onblur="clicaBotao()" name="dn">
<input type="submit" id="buton" name="calcula" value="CALCULAR">
</form>
<script>
function clicaBotao() {
buton.click();
}
</script>
</body>
</html>
<?php
date_default_timezone_set('Europe/Lisbon');
$dn = new DateTime ($_POST['dn']);
$hoje = new DateTime(Date());
$idade = $hoje ->diff ($dn);
echo "Tem {$idade->y} anos e {$idade->m} meses de idade";
?>
After typing in the birth date, when you exit the DateTime
age calculation is performed.
Only the DateTime field is deleted and I want it to be kept, to be entered in the database. How can I get around this?