AJAX and date formatting

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
jurriemcflurrie
Forum Commoner
Posts: 61
Joined: Wed Jul 06, 2005 7:14 am
Location: Den Haag, the Netherlands

AJAX and date formatting

Post by jurriemcflurrie »

Hey I'm having trouble with date formatting in my ajax application. I'm using the Zend Framework and the prototype.js library.

I used to format my dates in the view. But now when I make an ajax request to the same data, this is what I do in the controller:

Code: Select all

   public function postDispatch() {
        if($this->getRequest()->isXmlHttpRequest()) {
            $this->_helper->json($this->view->getVars(), null, true);
        }
    }
This will return the unformatted timestamp to the client. I don't want to format it with javascript, because I don't want to do the same thing twice.

My guess is to format it in the model, but I don't have a clue on how to do this properly.

Any suggestions?
Post Reply