Not sure what’s going on, but I can’t save the date submitted by form data, it always saves 0000-00-00.
<?php echo $form->labelEx($model,'svc_date'); ?>
<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'model' => $model,
'attribute' => 'svc_date',
'options' => array(
'appendText' => ' - mm/dd/yyyy',
'dateFormat' => 'mm/dd/yy'
<?php echo $form->error($model,'svc_date'); ?>
I thought that maybe this was due to input not being an actual date, so I added a conversion event:
protected function beforeSave()
$this->svc_date = date('m/d/Y', strtotime($this->svc_date));
but this made no difference.
MySQL field is set to DATE
You change the dateFormat in widget in the following way.
'dateFormat' => 'yy-mm-dd'
Then there is no need to override the beforSave method.
Ah, this works well, thank you! Much appreciated.
How do I go about setting my desired date and time format? Is this constraint due to MySQL table field?
MySQL is only accepting english notation, therfore you have to add a conversion layer between user input and db.
For this you could use a behavior like i18n-datetime-behavior
(if you decide to use this extensions also take a look at the valueable comments that other users made, especially this and this. Could you save some debugging issues… )
Nice, I’ll be looking into that.