Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

update model with current date
 
simoninman
Jr. Member
 
Avatar
Total Posts:  18
Joined:  2013-03-25
 

Hi

I am looking to have a created_at column in my model however i cannot seem to set the default value to current_timestamp in my database as it is causing an error
is there a way in my saveAction i can set the created_at timestamp?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Krish_TechnoLab
Jr. Member
 
Total Posts:  29
Joined:  2014-02-03
India
 

Try using below code.

if ($model->getCreatedAt() == NULL
{
    $model
->setCreatedAt(Varien_Date::toTimestamp(now()));
}

Krish TechnoLabs
http://www.krishtechnolabs.com/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top