- 
      
- 
        Save pgroot91/893ecd4fd9b8ed90043a496e85d46cec to your computer and use it in GitHub Desktop. 
    Convert WordPress date format to jQuery UI DatePicker format
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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 ); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment