admin管理员组文章数量:1327982
I'm having a little (and annoying) problem in Wordpress. I'm using a Restaurant Reservation plugin. Everything works fine, all date format are well translated in my language (Italian). All website is set to it_IT.
However, there is a Control Panel inside my Wordpress Admin Panel, in which the date is still in English:
The code that returns that date is:
case 'qrr_date':
$date_str = $model->get_date();
if (!empty($date_str)){
$date_obj = new DateTime( $date_str );
$format = apply_filters( 'qrr_admin_booking_column_date', 'j F Y, H:i');
echo $date_obj->format($format);
I'm trying to use the date_i18n() function in order to have everything in my lang. But I think i'm using it wrongly (or maybe some strings are corrupted).
I tried:
echo date_i18n($date_obj->format($format));
But this is what it returns:
22 J000000lunedi20 2020, 20:15
It's like "July" is "J000000lunedi20", but of course it should be "Luglio".
Am I doing something wrong? I'm not good in PHP. This is not my field :( I hope you can help me with that.
I'm having a little (and annoying) problem in Wordpress. I'm using a Restaurant Reservation plugin. Everything works fine, all date format are well translated in my language (Italian). All website is set to it_IT.
However, there is a Control Panel inside my Wordpress Admin Panel, in which the date is still in English:
The code that returns that date is:
case 'qrr_date':
$date_str = $model->get_date();
if (!empty($date_str)){
$date_obj = new DateTime( $date_str );
$format = apply_filters( 'qrr_admin_booking_column_date', 'j F Y, H:i');
echo $date_obj->format($format);
I'm trying to use the date_i18n() function in order to have everything in my lang. But I think i'm using it wrongly (or maybe some strings are corrupted).
I tried:
echo date_i18n($date_obj->format($format));
But this is what it returns:
22 J000000lunedi20 2020, 20:15
It's like "July" is "J000000lunedi20", but of course it should be "Luglio".
Am I doing something wrong? I'm not good in PHP. This is not my field :( I hope you can help me with that.
Share Improve this question asked Jul 20, 2020 at 8:28 mois23mois23 11 Answer
Reset to default 0So to see how that date_i18n
function works you can search for it, then hopefully find the documentation.
That's here: https://developer.wordpress/reference/functions/date_i18n/
It's technical to read it, but what it says is that the first parameter on the function is not the date you want to translate but the date format that you want the date in, and the second is the time in a timestamp format. (It exlpains that weird output because you're giving it a date where it's expecting a date format string)
So what you probably want is:
echo date_i18n($format, $date_obj->getTimestamp());
I didn't test this, but looking at docs for DateTime here https://www.php/manual/en/class.datetime.php , it looks like it should be right.
Post again if it doesn't work.
本文标签: pluginsProblem with Date translation in Wordpress
版权声明:本文标题:plugins - Problem with Date translation in Wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742248463a2440299.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论