
The initial code:
$this->widget(‘zii.widgets.jui.CJuiDatePicker’, array(
‘name’=>’mendtime’,
‘value’=>date(‘Y-m-d’, time()),
‘language’=>Yii::app()->getLanguage(),
‘options’=>array(
‘showAnim’=>’slideDown’,
‘changeYear’=>true,
‘changeMonth’=>true,
‘showWeek’=>true,
‘autoSize’=>true,
‘dateFormat’=>’yy-mm-dd’,
‘maxDate’=>’0’,
‘minDate’=>’-10d’,
),
‘htmlOptions’=>array(
‘readonly’=>’readonly’,
‘class’=>’txt’,
‘style’=>’width:200px’
)
));
The final implementation effect:

Implementation process:
1. Download the extension from the official Yii website: http://www.yiiframework.com/extension/datetimepicker/
2. Copy the CJuiDateTimePicker folder to the protected\extensions directory;
3. Download the language pack from https://github.com/trentrichardson/jQuery-Timepicker-Addon, because the Yii extension does not include a language pack;
4. In the file CJuiDateTimePicker.php, find: $cs->registerScriptFile($assets.self::ASSETS_NAME.’.js’,CClientScript::POS_END); and add the following line below it:
$cs->registerScriptFile($assets.’/i18n/jquery-ui-timepicker-‘ . $this->language . ‘.js’,CClientScript::POS_END);, to load the language pack;
5. Code in the view:
<?php
Yii::import(‘application.extensions.CJuiDateTimePicker.CJuiDateTimePicker’);
$this->widget(‘CJuiDateTimePicker’, array(
‘name’=>’mendtime’,
‘value’=>date(‘Y-m-d H:m:s’, time()),
‘language’=>Yii::app()->getLanguage(),
‘options’=>array(
‘showAnim’=>’slideDown’,
‘changeYear’=>true,
‘changeMonth’=>true,
‘showWeek’=>true,
‘autoSize’=>true,
‘dateFormat’=>’yy-mm-dd’,
‘timeFormat’=>’hh:mm:ss’,
‘maxDate’=>’0’,
‘minDate’=>’-10d’,
),
‘htmlOptions’=>array(
‘readonly’=>’readonly’,
‘class’=>’txt’,
‘style’=>’width:200px’
)
));
?>
Notes:
1. $this->language must match the one in the js file. It defaults to zh-CN, but if $this->language is set to zh_cn, you must update all instances to match $this->language; otherwise, it will not run correctly;
2. The date and time format settings are different from the date function in PHP. Instead, they are:
‘dateFormat’=>’yy-mm-dd’,
‘timeFormat’=>’hh:mm:ss’,

