Add the concrete implementation of hours, minutes and seconds in Yii’s CjuidatePicker!
The most 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
)
));
Post-realization:
Implementation process:
1. Extension download on the official website of yii:http://www.yiiframework.com/extension/datetimepicker/
2. Copy the cjuidateTimePicker folder to the protected\extensions directory;
3. tohttps://github.com/trentrichardson/jQuery-Timepicker-Addon下载语言包,因为yii扩展中没有语言包;
4. Look in the file CJUIDateTimePicker.php: $CS->RegisterScriptFile($assets.self::assets_name..js,cclientScript::pos_end); add a line under it:
$cs->registerScriptFile($assets./i18n/jquery-ui-timepicker-. $this->language ..js,cclientScript::pos_end); to load language packs;
5. The 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
)
));
?>
Note:
1. $this->language must be consistent with the js file, which defaults to zh-cn, and assumes that $this-> ;Language is zh_cn, then all need to be modified to be consistent with $this->language, otherwise the operation is abnormal;
2. The date and time format settings are inconsistent with the date in PHP, but
dateformat=>YY-MM-DD,
TimeFormat=>hh:mm:ss,

