简体   繁体   中英

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. 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

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

if I dump before save(). But it saves the null value in the table as:

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())));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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