• Resolved andreas.kastl

    (@andreaskastl)


    Hello!
    How is it possible to set the time via jquery function?

    I have in my form a radiobutton for “whole day event” and if this is set the timepicker will hide (that works) and the time should be set to an specific value OR it should be hidden.

    Is that possible?

    Many thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • I think it might be better to ‘rebuild’ the picker when that option changes.

    This is just an example code, that you can explore and adapt to your needs:

    datepickeropts.timepicker = 'off';
    datepickeropts.value = '12/14/2019';
    datepickeropts.format = 'MM\/DD\/YYYY';
    dtp_init();

    This switches off the timepicker, sets the date to a specific value, sets the format without the time and resarts the picker.
    The opposite would be something like:

    datepickeropts.timepicker = 'on';
    datepickeropts.value = '12/14/2019 15:00';
    datepickeropts.format = 'MM\/DD\/YYYY hh:mm A';
    dtp_init();

    The format will depend on what you have selected in the options and you might need to have the date value automatically, instead of hardcoded.

    This is already a customization and outside the support I can provide, but hope it helps.

    Greetings, Carlos

    Thread Starter andreas.kastl

    (@andreaskastl)

    Hi carlos!
    many thanks – that works!

    BUT I have one issue found – if the plugin is activated the times which will be shown on my site are 1 hour before the actual time.
    If i deactivate the plugin the time is correct.

    Thanks!

    Thread Starter andreas.kastl

    (@andreaskastl)

    EDIT:
    It seems that the UTC time will be taken instead of the local time because thats also one hour difference.
    Thanks!

    Hi @andreaskastl
    In the next update I’ll have some changes to how the plugin handles timezones.
    You can try the new version already downloading it directly from github at https://github.com/carmoreira/date-time-picker-field
    You can check if that new version doesn’t interfer with the time of your website.
    It would be helpful if you test and give me some feedback actually, so I know if it’s working for others also.
    Cheers, Carlos

    Thread Starter andreas.kastl

    (@andreaskastl)

    Hi Carlos!
    I have tried the new version …. IT WORKS!
    Many thanks – Great support!

    thank you for testing @andreaskastl and for the positive feedback.
    Cheers, Carlos

    Thread Starter andreas.kastl

    (@andreaskastl)

    sorry I have one more question:

    I’m not so familar with java – you told me I can change the value with this line:
    datepickeropts.value = ’12/14/2019 15:00′;

    I have in my form two datepickers, one for starttime one for endtime.
    How can I add a class or ID to this “datepickeropts.value = ’12/14/2019 15:00′;” that only the #starttime will be changed?

    Many thanks!

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change time via jquery?’ is closed to new replies.