datetime picker input widget, based on Jui-timepicker-addon
Yii framework with Zii lib.
extract to extensions folder.
put next code into view:
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker'); $this->widget('CJuiDateTimePicker',array( 'model'=>$news, //Model object 'attribute'=>'eventDate', //attribute name 'mode'=>'datetime' //use "time","date" or "datetime" (default) 'options'=>array() // jquery plugin options ));
Total 12 comments
I've found a simple, but not so pretty workaround to the language issue.
This should show English text and a DateTime formatted as: "2012/04/11 12:00"
You need 2 modifications to add a translation : in jquery-ui-timepicker-addon.js , function Timepicker() 1-Add the translation like
then register it at the end of the function :
Спасибо =)
antonywu´s workaround...
...works great and there´s no more need to force english language all the time. Thanks a lot! But the output string differs from original one instead of using default CJuiDateTimePicker settings:
I recommend to convert the string to an unix time stamp because it´s easier to handle. The necessary command should be:
Hi, tks for the extension!
I'm trying to show "hours", "minutes", "seconds" texts in a language different from "en"
I've created the proper array in the js file as
but only the calendar gets translated when I set the widget as
Please, what am I missing to get texts translated?
Thanks and regards!
I also dont get the times displaying. Is this something with the new version of Yii or something thats stopping this from working?
how come i dont see the time input, only date exists? i ve seen the original Ui.js istwork but this CJUI didtn
hi,
i want to use this widget outside a view so $this-> don't work.
i'm able to import the widget, but i'm not able to load it.
can you explain me please?
my code
[php] <?php $this->widget('CJuiDateTimePicker',array( 'model'=>Activity::model(), //Model object 'attribute'=>'activity_deadline', //attribute name 'mode'=>'datetime', //use "time","date" or "datetime" (default) 'options'=>array('dateFormat'=>'yy-mm-dd'), // jquery plugin options 'language' => '', )); ?>
i obtain
Fatal error: Using $this when not in object context in /var/www/tasker/task/task-new.php on line 20
In Vietnamese, the date time usually goes with : hh:ii:ss dd/mm/yy. I dive into the js code, and found out that there is no way I could change the order of date and time through configuration.
I use DateTimeI18Behavior to parse the date and time string, and the format ship with Yii is correct, but I cannot make the JQuery plugin to change to this format.
How can I convert the input format to correct output one?
@ianare Well, interesting that you mentioned about the other plugin. Here are some major differences 1. DateTimePicker inherits from Zii's DatePicker, so the implementation only has three files (compared to the TimePicker which has 21 files..) 2. The UI interaction is different. For DateTimePicker, you can click in the field, and the UI would pop up right away. With TimePicker, I would need to click on that "..." button in order to show the UI. 3. Finally, thanks to Zii, DateTimePicker supports far more languages than TimePicker does.
Now, it all comes down to your personal preference. For me, with minor changes (see my earlier post), it works like a charm for me.
What advantage over the existing plugin ?
http://www.yiiframework.com/extension/timepicker
So I noticed something odd with the extension but I highly suspect CJuiDatePicker is also affected. With the default settings, language is default to "en_us" The end result is that it will show DateTimePicker in Chinese characters. On the other hand, if I set language => '' (like below), DateTimePicker displays the language correctly (in English of course)
Since I don't want to force English language all the time, I ended up modifying the extension inside run() at line 47. That way, it will display the language correctly, and at the same time, reduce the need to load i8n script.
Leave a comment
Please login to leave your comment.