我需要以此格式2013-03-11#11 Mar | Mon
我发现Date函数没有返回意大利语翻译,因此我使用strftime。
但如何将日期添加到strftime?
setlocale(LC_ALL, 'it_IT');
for($i=0; $i<30; $i++){
echo $date = date("Y-m-d", strtotime('now + '.$i.' days'));
echo " # ";
echo $date_string = strftime("%d %b | %a" );
}
答案 0 :(得分:1)
您可以使用:
strftime("%d %b | %a",strtotime($date))
这将显示月份和日期。
答案 1 :(得分:1)
此代码似乎可以解决您的问题:
setlocale(LC_ALL, 'it_IT');
for($i=0; $i<30; $i++){
echo $date = date("Y-m-d", strtotime('now + '.$i.' days'));
echo " # ";
echo $date_string = strftime( "%d %b | %a", strtotime('now + '.$i.' days') ) . "<br>";
}
你遇到的问题是strftime正在使用默认日期,即今天。查看文档http://php.net/manual/en/function.strftime.php,您可以指定使用它的时间戳,这是您未来的日期(现在+ $ i),作为第二个参数。
享受!