I have a datetime field in a database table. However in some views I only want the date and not the time to echo. Is there a parameter I can add to textfield() to define this output?
Thanks,
Dubby.
I have a datetime field in a database table. However in some views I only want the date and not the time to echo. Is there a parameter I can add to textfield() to define this output?
Thanks,
Dubby.
date("d-M-Y",strtotime($model->myDateTime))
Sorry, I should have clarified. This is in the form. The code currently looks like:
<?php echo $form->textField($model,'invoiceDate'); ?>
How can I change the output here? I was hoping I could add something into the $options.
<?php
$model->invoiceDate = date("d-M-Y",strtotime($model->invoiceDate ));
echo $form->textField($model,'invoiceDate');
?>
note :you must convert again to mysql datetime format on beforesave()
hope it’s right…
OK, got it now. I was just wondering what the best practice was for Yii.
Thanks for the responses.
I use the same solution of fastcrash.
When I create internationalized website I use:
Yii::app()->dateFormatter->formatDateTime($model->invoiceDate ));
dateFormatter format the date according to the local conventions.
Yii::app()->dateFormatter->formatDateTime($model->invoiceDate ));
yes, you are right [color="#8B0000"]zaccaria[/color], that is the right thing to do it in yii way.
sorry, never play with CDateFormatter before.
my past still influen me to use traditional code style.
I found this widget very useful for my input view code:
$this->widget('CMaskedTextField',
array(
'mask'=>'99:99',
'model'=>$model,
'attribute'=>'start_time'
));
Should work for date as well something like "99/99/9999".
Check this
Great framework!
Hi!
How Can I include the CMaskedTextField to the CJuiDatePicker? Because each one creates a input field
Regards