0
I always want to show the previous Tuesday in the input and for that I do it this way:
$dia = new DateTime();
$dia->modify( 'previous tuesday' );
$terca = date($dia->format('d-m-Y'));
Then I want to show the variable $terca
in the value
of a input
type
date
, but it doesn’t show, only if it is datetime
:
<td style="float:center"> <input type="date" name= "data" value="<?php echo $terca?>"></td>
Whenever I run the page I get this warning:
The specified value "19-02-2019" does not conform to the required format, "yyyy-MM-dd".
You saw what the "required format" is in the error message?
– Woss
@Anderson Carlos Woss The "required format" is the
datetime
but I want the input to be likedate
in case you want to change the date the calendar appears. I have tried to convert the variable todate
but I still can’t see the date unless I use thedatetime
– Bruno
Do not confuse type with format. You tried to insert a value in the d-m-Y format into a field that requires the yyyy-MM-dd format. That’s exactly what the error message says.
– Woss
@Anderson Carlos Woss I’m trying this way
date('yyyy-MM-dd', strtotime($terca));
but I still have the same problem– Bruno