質問

background

I'm trying to set the default date and default time for this jquery plugin: http://trentrichardson.com/2010/04/19/timepicker-addon-for-jquery-ui-datepicker/

problem

The times change, but not to the value I specify. For example, for date I pass in a value of 2013-12-16, and it changes it to 12-16-2013. Timepicker is similar, I pass in '03:00:00' and it changes it to 8:00AM

The Code

The values are retrieved as strings from PHP.

$('#appointmentTime').timepicker({
       controlType: 'select',
       timeFormat: 'h:mm TT',
       ampm: true, 
       step: '15'
   });
$('#appointmentTime').timepicker('setTime', '<?echo $ascStudent->get("nextAppointmentTime")?>' );                                       
$('#appointmentDate').datepicker({dateFormat: 'mm-dd-yy'});
$('#appointmentDate').datepicker('defaultDate', '<?echo $ascStudent->get("nextAppointmentDate")?>');
役に立ちましたか?

解決

Figured it out.

Default date does not work datepicker despite some other SO answers (or at least not in my case). It also apparently needs to be pre-formatted for the widget, like so:

$('#appointmentDate').datepicker('setDate', '<?echo date("m-d-Y", strtotime(str_replace("-","/", $ascStudent->get("nextAppointmentDate")))); ?>');
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top