Ok
In my controller
/**
* @return \Phalcon\Http\ResponseInterface
*/
public function saveAction()
{
// Is not $_POST
if (!$this->request->isPost()) {
$this->view->disable();
return $this->response->redirect($this->router->getControllerName());
}
$id = $this->request->getPost('id', 'int', null);
$date = date('Y-m-d H:i:s');
if (!empty($id)) {
$object = User::findFirstById($id);
} else {
$object = new User;
$registerHash = md5(uniqid(rand(), true));
$randomPasswd = substr(md5(microtime()), 0, 7);
$object->setIdRole(2); //Role::ROLE_ADMINISTRATOR
$object->setPasswd($this->security->hash($randomPasswd));
$object->setRegisterhash($registerHash);
$object->setDateAdd($date);
$object->setStatus(User::STATUS_PENDING);
}
$object->setGender($this->request->getPost('gender'));
$object->setDateUpd($date);
$form = new UserForm($object);
$form->bind($_POST, $object);
// Form isn't valid
if (!$form->isValid($this->request->getPost())) {
foreach ($form->getMessages() as $message) {
$this->flashSession->error($message->getMessage());
}
// Redirect to edit form if we have an ID in page, otherwise redirect to add a new item page
return $this->response->redirect(
$this->router->getControllerName() . (!is_null($id) ? '/edit/' . $id : '/new')
);
} else {
if (!$object->save()) {
foreach ($object->getMessages() as $message) {
$this->flashSession->error($message->getMessage());
}
return $this->dispatcher->forward(
['controller' => $this->router->getControllerName(), 'action' => 'new']
);
} else {
$this->flashSession->success(t('Data was successfully saved'));
return $this->response->redirect($this->router->getControllerName());
}
}
}
Are you sure format date in Mysql $date = date('Y-m-d H:i:s');