试图用西班牙语显示日期 [英] Trying to display a date in Spanish
问题描述
$ oldLocale = setlocale(LC_TIME,'it_IT');
echo strftime(%a%d%b%Y,$ row ['eventtime']);
setlocale(LC_TIME,$ oldLocale);
我也尝试过这个
<?php
setlocale(LC_ALL,'it_IT');
$ originalDate =04/01/2014;
$ originalDate = date(d / m / Y,strtotime($ originalDate));
$ newDate = date(d M Y,strtotime($ originalDate));
echo $ newDate
?>
更新
我尝试过这个代码
setlocale(LC_TIME,'es_ES','Spanish_Spain','Spanish');
$ date = $ date = str_replace(/, - ,04/01/2014);
echo strftime('%d%B%Y',strtotime($ date));
所以现在显示 04 enero 2014
有没有办法让 enero
进入 ene
像短手?
这两个代码都只显示英文日期。任何帮助将不胜感激。
您真的应该在php.ini中设置您的区域设置,而不是动态设置。
而且,it_IT是意大利语区域,不是西班牙语区域。
您需要在第一个代码段中使用 strftime()
方法。
最后,不同操作系统上的区域设置名称不同。
尝试:
setlocale(LC_TIME,'es_ES'西班牙语西班牙语,西班牙语);
Nothing is working for me. Here is the code snippet I tried
$oldLocale = setlocale(LC_TIME, 'it_IT');
echo strftime("%a %d %b %Y", $row['eventtime']);
setlocale(LC_TIME, $oldLocale);
I have also tried this
<?php
setlocale(LC_ALL, 'it_IT');
$originalDate = "04/01/2014";
$originalDate =date("d/m/Y", strtotime($originalDate));
$newDate = date("d M Y", strtotime($originalDate));
echo $newDate
?>
UPDATE
I tried this code
setlocale(LC_TIME, 'es_ES', 'Spanish_Spain', 'Spanish');
$date = $date = str_replace("/","-","04/01/2014");
echo strftime('%d %B %Y',strtotime($date));
So now it's showing 04 enero 2014
but is there a way I can make enero
into ene
like short hand?
Both the code are showing date in English only. Any help would be appreciated.
You really ought to set your locale in php.ini, not dynamically.
And, it_IT is an Italian locale not a Spanish one.
You want the strftime()
method in the first code snippet.
Finally, locale names are different on different operating systems.
Try:
setlocale(LC_TIME, 'es_ES', 'Spanish_Spain', 'Spanish');
这篇关于试图用西班牙语显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!