How best to convert CakePHP date picker form data to a PHP DateTime object?

后端 未结 2 1881
长发绾君心
长发绾君心 2021-01-03 11:25

I\'m doing this in app/views/mymodel/add.ctp:

input(\'Mymodel.mydatefield\'); ?>

And then, in

2条回答
  •  抹茶落季
    2021-01-03 11:47

    I know this is an old question, but in case anyone else comes looking for an answer: CakePHP's generic Model class has a method, ::deconstruct(), that is used to handle this necessary logic internally. You can use it like this:

    $stringDate = $this->MyModel->deconstruct('fieldname', $arrayDate)
    

提交回复
热议问题