Opened 13 months ago
Last modified 13 months ago
#59423 new defect (bug)
Datepicker in wordpress do not follow the Date format set in the settings
Reported by: | rajeshsingh520 | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | External Libraries | Keywords: | reporter-feedback |
Focuses: | ui, javascript | Cc: |
Description
Go to wordpress > Settings > General
over there select "Date Format" > "Custom date" and set it to "jS F Y"
Once you do this it will show you date to be like this 21st September 2023
Now Add the below code in your theme function.php file this code will create a shortcode [datepicker]
<?php function enqueue_datepicker_20230921() { wp_enqueue_script('jquery-ui-datepicker'); wp_enqueue_style('jquery-ui-datepicker-style', 'https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css'); } add_action('wp_enqueue_scripts', 'enqueue_datepicker_20230921'); function datepicker_shortcode_20230921() { ob_start(); ?> <input type="text" id="datepicker"> <script> jQuery(document).ready(function($) { $("#datepicker").datepicker(); }); </script> <?php return ob_get_clean(); } add_shortcode('datepicker', 'datepicker_shortcode_20230921');
Once you have done this Create a page and add short code [datepicker]
go to the front end and select date in the Datepicker
if you select 22nd it will show the date as 22S September 2023
rather then 22nd September 2023
it does not convert S in to nd, st, or th on the front end
Change History (4)
#2
@
13 months ago
Hi,
but in the older version of wordpress it used to support nd, th, rd
we had a plugin that used to work with this but suddenly it has stopped so we are raising this ticket
example: 22nd 31st do you know what letter to use to show nd, st and rd next to the date
Hi and welcome to WordPress Core Trac!
The datepicker shortcode works with all four of the English preset options plus the lowercase
l
day of the week, but jQuery UI's datepicker does not support theS
English ordinal suffix.An old pull request was closed because it does not consider all locales. You could comment on that PR and/or open a new issue in the jQuery UI repository:
https://github.com/jquery/jquery-ui/issues
If/when they add support, WordPress could update to the latest version of the jQuery UI script.