• Resolved Guido

    (@guido07111975)


    Hi there,

    This is my datepicker code:

    jQuery(document).ready(function ($) {
    	$( "#date" ).datepicker({dateFormat: "dd-mm-yy"});
    });

    As you can see I have hardcoded the date format.

    For my frontend code I use this to get date format set in WP Dashboard > Settings > General:

    date_i18n( get_option( 'date_format' ), $date );

    Is it somehow possible to add this to the js datepicker file too?

    Guido

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Guido

    (@guido07111975)

    When I look at the jquery date formats I guess this wil not work because dateformat in WP can be different.. For example, WP dateformat j F Y will not work in jquery.

    Guido

    Guido,
    I’m a python guy…and a few weeks new to WP. Where did you put your original date picker code in your first post? My theme is pulling d/m/Y. I want it to be m-d-y.

    Appreciate your assistance in advance.
    Chris.

    Thread Starter Guido

    (@guido07111975)

    Hi Chris,

    There should be a JS file somewhere, in my case you can check the workaround in the FAQ of my plugin VSEL.

    Guido

    Thread Starter Guido

    (@guido07111975)

    A late response… but it’s possible using wp localize script and add the date variable there (see example on that page).

    Resolved.

    Guido

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Use php date format function in jQuery datepicker’ is closed to new replies.