Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-12-2007, 05:57 PM
Junior Member
 
Join Date: Oct 2007
Posts: 16
Default A flexible way to format timestamps?

Hello,
I'm rolling through a returned rowset, which stores dates as unix timestamps.
What's the most flexible way to output a timestamp as a formatted string, using Zend_Date?

Right now I'm doing it like this, for each row:
PHP Code:
<?php $date = new Zend_Date($row->postedZend_Date::TIMESTAMP); echo $date->toString('EEEE, dd MMMM yyyy');?>
It works allright, but the code doesn't that good...

What I'm looking for is something like this:
PHP Code:
class IndexController extends Zend_Controller_Action {
    
$date = new Zend_Date();
    
$date->setInputFormat(Zend_Date::TIMESTAMP);
    
$date->setOutputFormat('EEEE, dd MMMM yyyy');
    
$this->view->date $date;

And then to output a timestamp formatted as "EEEE, dd MMMM yyyy" you would do:
PHP Code:
<?php foreach($rowset as $row):?>
    <p><?php echo $this->date->format($row->posted)?><br /></p>
<?php endforeach;?>
Does Zend_Date support something similiar?
Or do I need a ViewHelper for this?

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 12:34 PM.