Title: wp_localize_jquery_ui_datepicker
Published: August 16, 2016
Last modified: May 20, 2026

---

# wp_localize_jquery_ui_datepicker()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#wp--skip-link--target)

Localizes the jQuery UI datepicker.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#source)󠁿

    ```php
    function wp_localize_jquery_ui_datepicker() {
    	global $wp_locale;

    	if ( ! wp_script_is( 'jquery-ui-datepicker', 'enqueued' ) ) {
    		return;
    	}

    	// Convert the PHP date format into jQuery UI's format.
    	$datepicker_date_format = str_replace(
    		array(
    			'd',
    			'j',
    			'l',
    			'z', // Day.
    			'F',
    			'M',
    			'n',
    			'm', // Month.
    			'Y',
    			'y', // Year.
    		),
    		array(
    			'dd',
    			'd',
    			'DD',
    			'o',
    			'MM',
    			'M',
    			'm',
    			'mm',
    			'yy',
    			'y',
    		),
    		get_option( 'date_format' )
    	);

    	$datepicker_defaults = wp_json_encode(
    		array(
    			'closeText'       => __( 'Close' ),
    			'currentText'     => __( 'Today' ),
    			'monthNames'      => array_values( $wp_locale->month ),
    			'monthNamesShort' => array_values( $wp_locale->month_abbrev ),
    			'nextText'        => _x( 'Next', 'datepicker: navigate to next month' ),
    			'prevText'        => _x( 'Previous', 'datepicker: navigate to previous month' ),
    			'dayNames'        => array_values( $wp_locale->weekday ),
    			'dayNamesShort'   => array_values( $wp_locale->weekday_abbrev ),
    			'dayNamesMin'     => array_values( $wp_locale->weekday_initial ),
    			'dateFormat'      => $datepicker_date_format,
    			'firstDay'        => absint( get_option( 'start_of_week' ) ),
    			'isRTL'           => $wp_locale->is_rtl(),
    		),
    		JSON_HEX_TAG | JSON_UNESCAPED_SLASHES
    	);

    	wp_add_inline_script( 'jquery-ui-datepicker', "jQuery(function(jQuery){jQuery.datepicker.setDefaults({$datepicker_defaults});});" );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/script-loader.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/script-loader.php#L1980)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/script-loader.php#L1980-L2035)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_add_inline_script()](https://developer.wordpress.org/reference/functions/wp_add_inline_script/)`wp-includes/functions.wp-scripts.php` |

Adds extra code to a registered script.

  | 
| [wp_script_is()](https://developer.wordpress.org/reference/functions/wp_script_is/)`wp-includes/functions.wp-scripts.php` |

Determines whether a script has been added to the queue.

  | 
| [WP_Locale::is_rtl()](https://developer.wordpress.org/reference/classes/wp_locale/is_rtl/)`wp-includes/class-wp-locale.php` |

Checks if current locale is RTL.

  | 
| [wp_json_encode()](https://developer.wordpress.org/reference/functions/wp_json_encode/)`wp-includes/functions.php` |

Encodes a variable into JSON, with some confidence checks.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [_x()](https://developer.wordpress.org/reference/functions/_x/)`wp-includes/l10n.php` |

Retrieves translated string with gettext context.

  | 
| [absint()](https://developer.wordpress.org/reference/functions/absint/)`wp-includes/load.php` |

Converts a value to non-negative integer.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_localize_jquery_ui_datepicker/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.6.0](https://developer.wordpress.org/reference/since/4.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_localize_jquery_ui_datepicker%2F)
before being able to contribute a note or feedback.