简体   繁体   English

如何在Magento数据库中存储日期时间值?

[英]How can I store a datetime value in my Magento database?

I am facing an error with storing date in the MySql database from my Magento backend module. 我从Magento后端模块在MySql数据库中存储日期时遇到错误。 I don't know why it happens only to me(the same code run smooth in my friend's backend). 我不知道为什么它只发生在我身上(同一代码在我朋友的后端运行顺畅)。 I am upto the save()- option in the saveAction(), and I can also see the date(like 我到了saveAction()中的save()-选项,而且还可以看到日期(例如

'created_time' => string '2014-09-13 13:41:15' (length=19)) 'created_time' => string '2014-09-13 13:41:15' (长度= 19))

if I dump before save(). 如果我在save()之前转储。 But it saves the null value in the table as: 但是它将空值保存在表中为:

0000-00-00 00:00:00 0000-00-00 00:00:00

Please ..I am waiting for your answers. 请..我正在等待您的答复。 Thank you. 谢谢。 Please notice: it is nothing about the syntax or logical errors. 请注意:与语法或逻辑错误无关。

在mysql datetime格式上,这对我有帮助:

$rec->addData(array('dt_something'=>date('Y-m-d H:i:s', time())));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM