2016-12-26 10 views
-1

私はスペイン語でcMonthをエコーし​​たいと思っています。何か案が?"日付"機能のスペイン語出力

if($_REQUEST["month"]>0){ 
    $cMonth = "0".intval($_REQUEST["month"]); 
    if ($_REQUEST["month"]>9) { 
     $cMonth = intval($_REQUEST["month"]); 
    } 
    $cYear = intval($_REQUEST["year"]); 
}else 
{ 
    $cMonth = date("m"); 
    $cYear = date("Y"); 
} 

echo date("F, Y",strtotime($cYear."-".$cMonth."-01")); 
+0

使用のstrftime(http://php.net/strftime)を使用することができます。この回答を見てください:http://stackoverflow.com/questions/4975854/translating-php-date-for-multilingual-site – yivi

答えて

1

こんにちはあなたは代わりに "日付" のこのMethodeのジャスト

setlocale(LC_ALL, "es_ES", 'Spanish_Spain', 'Spanish'); 
    $string = "27/12/2016"; 
    $date = \DateTime::createFromFormat("d/m/Y", $string); 
    echo strftime("%B", $date->getTimestamp()); 
+0

ありがとう!!しかし、私はよくここでどのように統合されているかわかりません: 日付( "F、Y"、strtotime($ cYear。 " - " $ cMonth。 " - 01")); – CosmicDisco

+0

私は問題が何であるかわかりません –

+0

@CosmicDisco、私はあなたがこのフォーマット "F、Y"で見てほしいと思うが、strftimeを使用したいと思う。 [strftime documentation](https://secure.php.net/manual/pt_BR/function.strftime.php)をチェックすることができます。 –