'Php Does not print date in input

PHP 5.3

Friends, I'm trying to insert the current date into an input, but it's not right, what do I do?

I tried everything and I can not find a solution, but in a normal echo it prints the input. The only "error" that is that warning in the browser console. The specified value "13-06-2019" does not conform to the required format, "yyyy-MM-dd".

In the beginning the page has:

<?php date_default_timezone_set('America/Sao_Paulo'); ?>

Prints: https://imgur.com/a/qhhlEdF

<?php $actualDate = date('d-m-Y'); echo $actualDate.' | '.date('Y-m-d');?>
<input type="date" class="form-control" name="dateRegister" id="dateRegister" value="<?php echo $actualDate; ?>" readonly>
<input type="text" class="form-control" name="dateRegister" id="dateRegister" value="<?php echo $actualDate; ?>" readonly>
<input type="date" class="form-control" name="dateRegister" id="dateRegister" value="<?php echo date('Y-m-d'); ?>" readonly>
<input type="text" class="form-control" name="dateRegister" id="dateRegister" value="<?php echo date('Y-m-d'); ?>" readonly>

[Warning]

The specified value "13-06-2019" does not conform to the required format, "yyyy-MM-dd".



Solution 1:[1]

Your code prints the value 13-06-2019 but requires a yyyy-MM-dd format.

Instead of $actualDate = date('d-m-Y') you need to set $actualDate = date('yyyy-MM-dd').

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Obsidian Age