我如何echo
荷兰语current date + 2 month
s`?
我尝试了以下内容:
<?php
setlocale(LC_TIME, 'NL_nl');
echo strftime('%e %B %Y'(' +2 month'));
?>
当我运行此代码时,我的页面出现错误。如何修复此问题并以荷兰语格式回显日期?
答案 0 :(得分:1)
我必须为它写一个基本字典,但这里是:
function dutch_strtotime($datetime) {
$days = array(
"maandag" => "Monday",
"dinsdag" => "Tuesday",
"woensdag" => "Wednesday",
"donderdag" => "Thursday",
"vrijdag" => "Friday",
"zaterdag" => "Saturday",
"zondag" => "Sunday"
);
$months = array(
"januari" => "January",
"februari" => "February",
"maart" => "March",
"april" => "April",
"mei" => "May",
"juni" => "June",
"juli" => "July",
"augustus" => "August",
"september" => "September",
"oktober" => "October",
"november" => "November",
"december" => "December"
);
$array = explode(" ", $datetime);
$array[0] = $days[strtolower($array[0])];
$array[2] = $months[strtolower($array[2])];
return strtotime(implode(" ", $array));
}
$date = "woensdag 22 oktober 2014 08:41:42";
echo date("l d-m-Y H:i:s", dutch_strtotime($date)) . "<br />";
echo date("d-m-Y", dutch_strtotime($date));
答案 1 :(得分:0)
$timestamp = time();
setlocale(LC_ALL, 'nl_NL');
strftime('%A, %B %d, %Y', $timestamp);
有关strftime click here的更多信息。
答案 2 :(得分:0)
月检查不正确
<?php
setlocale(LC_TIME, 'NL_nl');
echo strtotime(date("Y-m-d") . " +2 month");
?>
您的变量$months
function dutch_strtotime
和echo strftime('%e %B %Y'(' +2 month'));
检查
答案 3 :(得分:0)
使用strtotime获取此后两个月的日期时间戳。 https://secure.php.net/manual/en/function.strtotime.php
然后提供时间戳作为strftime的第二个参数
<?php
setlocale(LC_TIME, 'nl_NL');
$timestamp = strtotime("+2 months");
echo strftime('%e %B %Y', $timestamp);
?>