我有这个代码,它通过json_decode检索我最新的推文、它们的日期等。
<?php setlocale(LC_ALL, 'it_IT'); ?>
<?php include("twitter_auth.php");
echo "<ul style='color:#6E6E6E'>";
foreach ($twitter_data as $tweet)
{
if (!empty($tweet)) {
$text = $tweet->text;
$text_in_tooltip = str_replace('"', '', $text); // replace " to avoid conflicts with title="" opening tags
$id = $tweet->id;
$time = strftime('%d %B', strtotime($tweet->created_at));
$username = $tweet->user->name;
}
echo '<li><span title="'; echo $text_in_tooltip; echo '">'; echo $text . "</span><br>
<a href='"http://twitter.com/"; echo $username ; echo '/status/'; echo $id ; echo '"><small>'; echo $time; echo '</small></a> -
<a href="http://twitter.com/intent/tweet?in_reply_to='; echo $id; echo '"><small>rispondi</small></a> -
<a href="http://twitter.com/intent/retweet?tweet_id='; echo $id; echo '"><small>retweet</small></a> -
<a href="http://twitter.com/intent/favorite?tweet_id='; echo $id; echo '"><small>preferito</small></a></li>';
}
echo '</ul>';
?>
问题是$time输出类似于"03二月"的内容,即使有一个setlocale(LC_ALL,'it_it');。错误是什么?如何用意大利语输出日期?系统:PHP 5.4.11和nginx(在Ubuntu服务器上)。
编辑:我还运行了dpkg重新配置区域设置:
Generating locales...
en_US.UTF-8... up-to-date
it_IT.UTF-8... up-to-date
Generation complete.
虽然听起来很傻,但我解决了将行更改为:的问题
<?php setlocale(LC_ALL, 'it_IT.UTF-8'); ?>