0

I'm currently trying to do it that way:

// Creating date object  
$date = new Zend_Date(); 

// Adding to it 4 weeks
$date->add('4', Zend_Date::WEEK); // it's expire day                

// Getting date in integer(i guess it's unix timestamp yes?)
$date->get();

// Saving it to Mysql in field 'expire' with type Varchar

Then, when needed to get rows, that have date bigger(that haven't yet expired), than current I just add to SQL a simple statement WHERE expire >= $current_date.

Or there is better way to do it? Or how it happens usually?

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Somebody
  • 9,316
  • 26
  • 94
  • 142

1 Answers1

0

I would recommend using the native MySQL DATETIME column in your table. This is how you'd retrieve the date for MySQL:

$date->get('yyyy-MM-dd HH:mm:ss');
Sonny
  • 8,204
  • 7
  • 63
  • 134