Hello everyone,
First I had problems with getting date's into my db see here. Now I have problems with getting it into the database on the right format. This is my code:
public function editAction()
{
if($this->_request->getParam('id')){
$id = $this->_request->getParam('id');
$data = $this->_evtObj->selectOneRow($id);
// initialize the form
//var_dump($data);
$form = new JS_Form_EventForm();
$array = $data->toArray();
//$locale = Zend_Registry::get('locale');
$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 populates the form with dates from the db. In the db the date is saved like 2010-01-15. As you can see in the above example i tried out two things:
locale = new Zend_Locale();
$date1 = new Zend_Date($locale);
$date1->set($array[0]['evt_startdate']);
$array[0]['evt_startdate'] = $date1->get();
This shows the date like: '1262300400'
and:
$array[0]['evt_enddate'] = date('%d-%m-%Y',(string)$array[0]['evt_enddate']);
this shows the date like: '%01-%01-%1970'
I want the date to be shown like dd-mm-yyyy
How to deal with this? All this date business drives me mad.
I am running zf 1.9.6
any idea's?