Magento, 1 db field not saved

Posted by david parloir on Stack Overflow See other posts from Stack Overflow or by david parloir
Published on 2011-01-13T12:27:38Z Indexed on 2011/01/13 13:53 UTC
Read the original article Hit count: 169

Filed under:
|
|

Hi there,
I have a problem with 1 field of the db. With this code:

            $expireMonth = Mage::getStoreConfig('points_options/config_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 uncoment the die($expireData), I see the correct value, something like 2012-01-13 13:21:12.
The filed is defined as:

`expire_date` datetime NULL

Any thaughts?

edit: the solution is:

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

check out the "s" in my strtotime expression

© Stack Overflow or respective owner

Related posts about magento

Related posts about model