views:

29

answers:

1

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?

Thanks for the attention. :)

A: 

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