-1
Using the data from html in the php how to calculate age?
Date of birth on HTML:
<form method="POST" action="doc.php">
Nascimento: <input type="date" id="data" name="data">
</form>
In the php I call the date:
<?php
echo $_POST['data'];
//a data digitada no formulario html
//eh exibida no formato yyyy/mm/dd
?>
Now I use the function date
to know the current date, then I must create the variable $idade
. How to perform the calculation with this data?
<?php
$dataNasc = $_POST['data'];
$dataAtual = date('Y/m/d');
//portanto, como ficaria a variável idade?
$idade = ?;
echo "Idade é: $idade Anos";
?>
I took a look, it wasn’t quite that
– Elder Son
What is the difference? The question appears to be exactly the same, the
date
input (at least in Chrome and Edge) already in the formatYYYY-MM-DD
, which is compatible with the answers to the question I mentioned– Inkeliz
You want to calculate age and the quoted question explicitly does that. I can’t see how it wouldn’t be duplicate.
– Woss
Solved, Thanks !
– Elder Son