[wp-trac] [WordPress Trac] #59423: Datepicker in wordpress do not follow the Date format set in the settings

WordPress Trac noreply at wordpress.org
Thu Sep 21 12:21:16 UTC 2023


#59423: Datepicker in wordpress do not follow the Date format set in the settings
--------------------------------+-----------------------------
 Reporter:  rajeshsingh520      |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  External Libraries  |    Version:
 Severity:  normal              |   Keywords:  needs-patch
  Focuses:  ui, javascript      |
--------------------------------+-----------------------------
 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
 <?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

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/59423>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list