开发者

Magento, 1 db field not saved

开发者 https://www.devze.com 2023-02-05 00:26 出处:网络
I have a problem with one field of the DB. With this code: $expireMonth = Mage::getStoreConfig(\'points_options/con开发者_运维问答fig_points/expiration_period\', Mage::app()->getStore()->getId

I have a problem with one field of the DB. With this code:

$expireMonth = Mage::getStoreConfig('points_options/con开发者_运维问答fig_points/expiration_period', Mage::app()->getStore()->getId());

if (!is_null($expireMonth) && ($expireMonth > 0)) {
    $expireDate = date("Y-m-d H:i:s", strtotime("+" . $expireMonth . " month"));
} else {
    $expireDate = NULL;
}

//die($expireDate);
//store in points history table
$this->_pointsModel->setCustomerId($this->_customer->getId())
                   ->setOrdersId('welcome')
                   ->setPointsPending($pointsForNewCustomer)
                   ->setPointsComment(Mage::helper('points')->__('welcome points'))
                   ->setDateAdded(date('Y-m-d H:i:s'))
                   ->setPointsStatus(2)//confirmed
                   ->setPointsType('WE')
                   ->setStoreId(Mage::app()->getStore()->getId())
                   ->setExpireDate($expireDate)
                   ->save();

Every field is saved in the table, except for expire_date. If I uncomment the die($expireData), I see the correct value, something like 2012-01-13 13:21:12. The field is defined as:

`expire_date` datetime NULL

Any thoughts?

edit: The solution is:

$expireDate = date("Y-m-d H:i:s", strtotime("+" . $expireMonth . " months"));

Check out the "s" in my strtotime expression.


I know many attributes allow for some sort of formatting before writing and after reading. Have you tried setting the value as a unix timestamp instead?

0

精彩评论

暂无评论...
验证码 换一张
取 消