我有一个CakePHP应用程序,允许用户注册和发布项目。在某些时候,而我一直在摆弄它我设法改变被创建的用户记录时,当前日期被捕获的方式:(当创建一个新的用户帐户的日期默认为CakePHP:注册用户不会保存正确的日期
Jan 19th 1970, 01:00
这里在用户控制我的注册动作:
function register()
{
if (!empty($this->data)){
if ($this->data['User']['password']
== $this->Auth->password($this->data['User']['password_confirm'])) {
$this->User->create();
if ($this->User->save($this->data)){
$this->redirect(array('action' => 'index'));
}
} else {
$this->Session->setFlash('password mismatch');
}
}
}
注册视图:
<?php
$currentdatetime = time();
echo $form->create('User', array('action' => 'register'));
echo $form->input('username', array('label' => 'Username'));
echo $form->input('fname', array('label' => 'First name'));
echo $form->input('lname', array('label' => 'Last name'));
echo $form->input('emailaddress', array('label' => 'Email Address'));
echo $form->input('website', array('label' => 'Website'));
echo $form->hidden('created', array('value' => $currentdatetime));
echo $form->input('password', array('label' => 'Password', 'type' => 'password'));
echo $form->input('password_confirm', array('label' => 'Retype Password', 'type' => 'password'));
echo $form->submit();
echo $form->end();
?>
我有一个创建DATETIME列用户表不为空,默认为“0000。 -00-00'
有人可以帮我吗?我想我也许只是删除了一条线鳕鱼什么的
致谢,
Jonesy
没有日期数据供我们调试。你必须验证几件事情......日期如何从视图传递给控制器?如果格式不正确,那就是你的问题。 – Stephen 2010-10-19 20:47:54
没有抱歉,只是格式我显示在视图中的日期时间。我更新了代码,看起来像我认为的那样。但它不起作用,也许你可以帮忙? – iamjonesy 2010-10-19 20:58:41