0

I have create an model in magento at a custom module and in that model i have create table and that table have a date field and i want save my current date in that date field but it becomes inserted value null at that table

Table Sql:

CREATE TABLE IF NOT EXISTS `social` (
  `social_id` int(10) NOT NULL AUTO_INCREMENT,
  `image` text NOT NULL,
  `likes` int(10) DEFAULT NULL,
  `caption_text` text,
  `comments` int(10) DEFAULT NULL,
  `insert_time` date DEFAULT NULL,
  PRIMARY KEY (`instagram_id`),
  KEY `likes` (`likes`,`insert_time`),
  KEY `comments` (`comments`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=21 ;

Model insert code:

$data=array(
'image'=>$url,
'likes'=>$item->likes->count,
'caption_text'=>$item->caption->text,
'comments' =>$item->comments->count,
'insert_time'=>date ('Y-M-d'), 
);
$model=Mage::getModel('social/social')->addData($data);
$model->save();

Why in date filed insert_time save all value as Null instead of current date?

1

date('Y-M-d') will produce 2015-Jan-14 and you probably want date('Y-m-d') which will give you 2015-01-14

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.