I tried to do with isset
, type:
$var1 = isset($_POST["namedocampo"]) ? $_POST["namedocampo"] : date('d/m/Y');
And with if
, type:
if ($_POST["namedocampo"] == "") {
$var1 = date('d/m/Y');
}
But whenever the field is not filled in, the date 31/12/1969
appears.
The date entry field looks like this:
<input type="text" id="iddocampo" name="namedocampo" class="form-control" maxlength="10" placeholder="dd/mm/aaaa" onkeyup="formatar('##/##/####', this, event)"></label>
And the output field looks like this:
<li class="list-group-item">
<span class="badge"><?php echo date("d-m-Y",strtotime($var1)); ?></span>
Data:
</li>