From what I understand, the best way to handle dates in the Zend Framework is to select them as a Unix timestamp from the database.
Quickly create dates from database date values
// SELECT UNIX_TIMESTAMP(my_datetime_column) FROM my_table
$date = new Zend_Date($unixtimestamp, Zend_Date::TIMESTAMP);
I think the pain is that there is no easy way in Oracle to select dates as Unix timestamps or in ISO-8601 format that best fit the two formats Zend_Date.
But I wrote a function to select dates as unix timestamps in PL / SQL, so I can really do it now.
Using Zend_Db_Expr, now I can select my dates as Unix timestamps:
$select = $db->select()
->from(array('p' => 'products'),
array(
'product_id',
'product_date' => new Zend_Db_Expr('toUnixTimestamp(product_date)')
)
);
$results = $db->fetchAll($select);
You would use a similar query for any RDMS - most of them have a timestamp function.
, $results, Zend_Date :
foreach($results as $result){
$productDate = new Zend_Date($result['product_date'], Zend_Date::TIMESTAMP);
echo $productDate->toString('dd/MMM/yyyy HH:mm:ss');
}
, $results, Zend_Date. , .
, :
- Zend_Db, - - , Zend_Date?