I am trying to make a date input that defaults to the value that is already in the database.
However, when I set the month, year, and date to the database values, the month, date, and year attributes are set on the select element but the page still displays the current date as the default values. When the form is submitted, today's date is stored in the database.
Heres the code:
$mail_date_time = \explode(" ",$campaign["MailedDate"]);
$mail_date = explode("-",$mail_date_time[0]);
echo $this->Form->create("Campaign");
echo $this->Form->input("MailedDate",array(
'month' =>strtotime($mail_date[1]),
'year' => strtotime($mail_date[0]),
'day' => strtotime($mail_date[2])
));
echo $this->Form->end("Submit");
$mailed_date turns out to be: [0]=2009 [1]=11 [2]=11
Does anyone know how to solve this? Thanks!
Y-m-d
format doesn't work? – marian0