naveed1
(ndk)
November 22, 2014, 10:49am
1
hello everyone.
I am using this extension http://www.yiiframework.com/extension/ejuidatetimepicker/ to retrieve the time field value and my form is
<?php
$this->widget('common.extensions.timepicker.EJuiDateTimePicker',array(
'model'=>$model,
'attribute'=>'end_time',
'timePickerOnly' => 'true',
'options'=>array(
'timeFormat' => 'h:m',
'changeMonth' => true,
'changeYear' => false,
),
));
?>
but it saves the time in hh:mm:ss format. the time field type in database table is TIME and I want that on frontend view it should display the time in hh:mm format.
So how can I do this ?
Thanks in advance.
Use the following code in your _view.php:
<b><?php echo CHtml::encode($data->getAttributeLabel(‘doe’)); ?>:</b>
<?php echo date("d-m-Y H:i", strtotime(CHtml::encode($data->doe))) ?>
<br />
If you want to display the same in some other view(page) do let me know.
naveed1
(ndk)
November 23, 2014, 4:10pm
3
Use the following code in your _view.php:
<b><?php echo CHtml::encode($data->getAttributeLabel(‘doe’)); ?>:</b>
<?php echo date("d-m-Y H:i", strtotime(CHtml::encode($data->doe))) ?>
<br />
If you want to display the same in some other view(page) do let me know.
thank you dear for your reply. but I have solved it by myself. thanks a lot dear.
well one thing that is left is to set the AM/PM option with the time e.g. 3:45 PM or 9:19 AM etc.
Just add "A" if you want to display AM/PM or "a" to display in lower case am/pm.
<?php echo date("g:i A", strtotime(CHtml::encode($data->doe))) ?> //"g" gives a 12 hour time format
Click the plus button if you think my solutions are helping you out.