我试图在duth中从DB中取出日期。我把日期分成单独的月,日和年变量,并将月份数改为文本,但现在我需要进入荷兰语而不是英语。我发现了一些有关它的信息,如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 :(得分:1)
<?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格式。如果我有任何错误,请指导我