2017-04-11 19 views
0

私はduthでDBから私の日付を取得しようとしています。 Imは別々の月、日、年の変数に日付を分割し、月の数値をテキストに変更しましたが、今は英語の代わりにダッチに入る必要があります。私はそれについての情報をsetlocale(LC_ALL, 'nl_NL')のように見つけましたが、うまくいきません。オランダで月の名前を取得

<?php 

     include_once("db/db.php"); 
     $statement = $db_con->prepare("select * from news_article where id > :id"); 
     $statement->execute(array(':id' => 0)); 
     $list = $statement->fetchAll(PDO::FETCH_ASSOC); 
    ?>  
<?php 
    foreach($list as $col) 
    { 
     // splitting into seperate month day year 
     $orderdate = explode('-', $col['datum']); 
     $year = $orderdate[0]; 
     $month = $orderdate[1]; 
     $day = $orderdate[2]; 

     $dateObj = DateTime::createFromFormat('!m', $month); 
     $monthName = 
     $dateObj->format('F'); 


     ?> 
//this needs to output in dutch 
<p class="month"><?php echo $monthName ?></p> 
+0

見てくださいhttp://stackoverflow.com/questions/13845554/php-date-get-name-of-months-in-local-language –

+0

DateTime :: format ()はロケールを認識していません(http://php.net/manual/en/datetime.format.php#refsect1-datetime.format-notes)。代わりにstrftime()を使用してください –

答えて

0
<?php 
$f = date('F'); 
    function dutch_format($value) { 

     $months = array(
      "January" => "januari", 
      "February" => "februari", 
      "March" => "maart", 
      "April"  => "april", 
      "May"  => "mei", 
      "June"  => "juni", 
      "July"  => "Juli", 
      "August" => "augustus", 
      "September" => "september", 
      "October" => "oktober", 
      "November" => "november", 
      "December" => "december" 
     ); 

     return $months[$value]; 
    } 
    echo $f; 
    echo "<br/>"; 
    echo dutch_format($f); 
?> 

それはDUTCH形式を返します。私が間違いをした場合は私に案内してください

+0

'strftime'とロケールの使用を検討してくださいそれ。 50言語のシステムを維持しなければならない場合、あなたの解決策はかなり手の届かないかもしれません... –

関連する問題