I am new to cakephp and i have the following problem!
In my app a have a date input field witch takes date from jquery datepicker.The date format from date picker is dd-mm-yyyy but when i press the submit button it cant be saved to database date field and i recieve in database a value of 0000-00-00.
How can i convert the submited value to yyy-mm-dd format before it is saved to db?
public function beforeMarshal(Event $event, ArrayObject $data, ArrayObject $options)
{
if (isset($data['myStringDate'])) {
$data['myStringDate']) = (new Time($data['myStringDate']), 'America/Toronto'))->setTimezone('UTC');
}
}
That should works. And do not forget to put on the top of your table file
I think its better set cake configuration for your locale format so cake handles automatically the format conversion from/to database/print in all date / decimal type fields.