Cjuidatepicker With Time ?

Hi All

I use CJuiDatePicker but I want to select both date and time (day month year hour minute and second)

I can’t find how CJuiDatePicker allow me to enter an extra string (the time) in textbox. (it prevents me when I try to enter a space or : over of the date string)

Also there is no something like CJuiDateTimePicker in core Yii and I don’t want to use an already third extension for this issue.

Note: I use DateTime type for this field in mysql (not Date)

Does anyone knows how to fix that?


Dear Friend

We can solve this issue in two ways.

1.On server side before saving the value, we can call

$model->publishDate=$model->publishDate." ".date("H:i:s");

2.On client side we can make use of datepicker.onSelect method.







		       function JSClock() {

                          var time = new Date();

                          var hour = time.getHours();

                          var minute = time.getMinutes();

                          var second = time.getSeconds();

                          var temp="";

                          temp +=(hour<10)? "0"+hour : hour;

                          temp += (minute < 10) ? ":0"+minute : ":"+minute ;

                          temp += (second < 10) ? ":0"+second : ":"+second ;

                          return temp;



			$(this).val($v+" "+JSClock());









1 Like

Bravo seenivasan!

Very good, although I mean that the user should be able to change the time manually and enter another time except the current time of the client,

I you have already the code to do that I apreciated to share it :)

otherwise I seek to find a solution

I give you a vote for your time and for the good work :)