-1

Using this plugin I am able to initialize the datetimepicker control to a specific format for both date and time like this

$.datepicker.regional['cur'] = { dateFormat: 'yy-mm-dd', showSecond: true, timeFormat: curtimeFormat };
$.datepicker.setDefaults($.datepicker.regional['cur']);
var datetimeParams = { showSecond: true, timeFormat: curtimeFormat };
$('#sampledateSett').datetimepicker(datetimeParams);

However my task is to let the user change the format and to keep showing him a sample date in the format he specified. I have 2 separate controls for date and time formats and a function I am running on every change to their values:

function TranslateAndSetTimeFormat(sqlDateFormat, sqlTimeFormat, dtcontrol) {
    var dtoptions = { dateFormat: sqlDateFormat, timeFormat: sqlTimeFormat, ampm: showampm, showSecond: false };
    $.datepicker.setDefaults(dtoptions);        
    dtcontrol.datetimepicker(dtoptions);        
    dtcontrol.datetimepicker("setDate", (new Date()));
}

I found that the format of the date changes to the new one when this function executes, but the time format remains stuck to whatever the control was initialized with. Need ideas on how to get the new timeFormat options to apply or how to re-initialize this control.

user1250290
  • 123
  • 3
  • 12

1 Answers1

0

using datetimepicker("destroy") option allows it to be reset with new options. Found the answer here: Change option dynamically in JQuery UI DatePicker fails

Community
  • 1
  • 1
user1250290
  • 123
  • 3
  • 12