/ Published in: PHP
This is a simple bit of code that allows you to do a write once date format in a PHP style date() format and convert it to be used by datepicker jQuery UI widget. It returns the converted string.\r\n\r\nNothing fancy here, but a time saver for the future.\r\n\r\nCould use improvement such as error handling for common PHP dateFormat string values that do not have an equivalent UI portion. Potentially make this a two way conversion. Add more available options.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function dateStringToDatepickerFormat($dateString) { //day 'd', //day of the month 'j', //3 letter name of the day 'l', //full name of the day 'z', //day of the year //month 'F', //Month name full 'M', //Month name short 'n', //numeric month no leading zeros 'm', //numeric month leading zeros //year 'Y', //full numeric year 'y' //numeric year: 2 digit ); 'dd','d','DD','o', 'MM','M','m','mm', 'yy','y' ); foreach($pattern as &$p) { $p = '/'.$p.'/'; } }