At first I had problems getting the date in my db see here . Now I have problems getting it in the database in the correct format. This is my code:
public function editAction()
{
if($this->_request->getParam('id')){
$id = $this->_request->getParam('id');
$data = $this->_evtObj->selectOneRow($id);
$form = new JS_Form_EventForm();
$array = $data->toArray();
$locale = new Zend_Locale();
$date1 = new Zend_Date($locale);
$date1->set($array[0]['evt_startdate']);
$array[0]['evt_startdate'] = $date1->get();
$array[0]['evt_enddate'] = date('%d-%m-%Y',(string)$array[0]['evt_enddate']);
$form->populate($array[0]);
$this->view->form =$form;
}
As you can see, it fills out the form with dates from db. In db, the date is saved as 2010-01-15. As you can see in the above example, I tried two things:
locale = new Zend_Locale();
$date1 = new Zend_Date($locale);
$date1->set($array[0]['evt_startdate']);
$array[0]['evt_startdate'] = $date1->get();
Date is displayed here: "1262300400"
and
$array[0]['evt_enddate'] = date('%d-%m-%Y',(string)$array[0]['evt_enddate']);
it shows the date: "% 01-% 01-% 1970"
I want the date displayed as dd-mm-yyyy
How to deal with it? This whole thing dates me crazy.
I am running zf 1.9.6
any idea?
source
share