Page 1 of 1

AJAX and date formatting

Posted: Thu Jan 17, 2008 7:59 am
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?