I wrote the following function to convert the current WordPress date format into a format that can be recognized by the jQuery UI Datepicker:

From: http://codex.wordpress.org/Formatting_Date_and_Time

To: http://docs.jquery.com/UI/Datepicker/formatDate

 * Convert a date format to a jQuery UI DatePicker format  
 * @param string $dateFormat a date format 
 * @return string 
function dateFormatTojQueryUIDatePickerFormat($dateFormat) { 

    $chars = array( 
        // Day
        'd' => 'dd', 'j' => 'd', 'l' => 'DD', 'D' => 'D',
        // Month 
        'm' => 'mm', 'n' => 'm', 'F' => 'MM', 'M' => 'M', 
        // Year 
        'Y' => 'yy', 'y' => 'y', 

    return strtr((string)$dateFormat, $chars); 

Anyone know of any easier/built-in way to accomplish this?


as for the document of the datapicker UI , I believe you do not need this function . the document specifies that you can use the following formats :

COOKIE - 'D, dd M yy'
ISO_8601 - 'yy-mm-dd' 

which are ,IMHO, compatible . At any rate , there are many PHP functions that will help you do time - converstion, you should look at some of them here :


For example :

you could also define that in Jquery directly like this :

Date.firstDayOfWeek = 0;
Date.format = 'yyyy-mm-dd';

If none of these solutions suit you there is also a specific plugin that might help :



Couldn't find anything built in to WP to do this, but there's a good tutorial on this site for setting something up like this:

This does not support custom format so I recommend using the original post function


You can also find a Gist of the code here:


Basically it uses a PHP function with switch instead for the supported formats WordPress uses. Check out the site though because it gives good details on what you should use for i18n support in date picker

function date_format_php_to_js( $sFormat ) {
    switch( $sFormat ) {
        //Predefined WP date formats
        case 'F j, Y':
            return( 'MM dd, yy' );
        case 'Y/m/d':
            return( 'yy/mm/dd' );
        case 'm/d/Y':
            return( 'mm/dd/yy' );
        case 'd/m/Y':
            return( 'dd/mm/yy' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.