Convert WordPress date format to jQuery UI DatePicker format
gistfile1.php
if( ! function_exists( 'wp_date_format_php_to_js') ){
/**
* Convert a date format to a jQuery UI DatePicker format
*
* @param string $dateFormat a date format
*
* @return string
*/
function wp_date_format_php_to_js( $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 );
}
}
No comments yet.