Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/247.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何用我的语言显示月份名称_Php_Mysql - Fatal编程技术网

Php 如何用我的语言显示月份名称

Php 如何用我的语言显示月份名称,php,mysql,Php,Mysql,你好,我有两个月和年的变量。我想用我的语言显示月份名称,但我无法使其正常工作。这是我的密码 setlocale(LC_TIME, array('ro.utf-8', 'ro_RO.UTF-8', 'ro_RO.utf-8', 'ro', 'ro_RO', 'ro_RO.ISO8859-2')); $luna=$_GET['month']; $an=$_GET['year']; $dateObj = DateTime::createFromFormat('!m', $luna); $mo

你好,我有两个月和年的变量。我想用我的语言显示月份名称,但我无法使其正常工作。这是我的密码

setlocale(LC_TIME, array('ro.utf-8', 'ro_RO.UTF-8', 'ro_RO.utf-8', 'ro', 'ro_RO', 'ro_RO.ISO8859-2')); 

$luna=$_GET['month'];
$an=$_GET['year'];

$dateObj   = DateTime::createFromFormat('!m', $luna);
$monthName = $dateObj->format('F');
$data='Arhiva '.$monthName.' - '.$an.'';

它显示的是2014年6月,我希望Iunie 2014 June=Iunie在我的国家。link给出的月份是dinamic,可以是任何数字。

试试这个

setlocale(LC_TIME, 'fr_FR'); 
$monthName  = strftime("%B",mktime(0, 0, 0, $_GET['month']));
echo  $monthName ; //It outputs month name in your local language that you have set in 'setlocale'  
在本例中,它被设置为法语。类似地,您可以通过传递语言代码将其用于您的区域设置,如:

sr_BA - Serbian (Montenegro);
sr_CS - Serbian (Serbia);
sr_ME - Serbian (Serbia and Montenegro);

快乐编码

您可以使用
strftime
():

您可以使用函数进行转换

setlocale(LC_TIME, array('ro.utf-8', 'ro_RO.UTF-8', 'ro_RO.utf-8', 'ro', 'ro_RO', 'ro_RO.ISO8859-2')); 

$luna=$_GET['month'];
$an=$_GET['year'];

$dateObj   = DateTime::createFromFormat('!m', $luna);
$monthName = strftime('%B', $dateObj->getTimestamp());
$data='Arhiva '.$monthName.' - '.$an.'';
$dateObj   = DateTime::createFromFormat('!m', $luna);

$formatter = new IntlDateFormatter("ro_RO",
                                    IntlDateFormatter::FULL, 
                                    IntlDateFormatter::FULL, 
                                    'Europe/Bucharest', 
                                    IntlDateFormatter::GREGORIAN,
                                    'MMMM');

echo $formatter->format($dateObj).' - '.$an; // Iunie - 2014