将PHP date()样式的dateFormat转换为等效的jQuery UI datepicker字符串
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了将PHP date()样式的dateFormat转换为等效的jQuery UI datepicker字符串相关的知识,希望对你有一定的参考价值。
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. Nothing fancy here, but a time saver for the future. Could 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.
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.'/'; } }
以上是关于将PHP date()样式的dateFormat转换为等效的jQuery UI datepicker字符串的主要内容,如果未能解决你的问题,请参考以下文章