7

I have this code which through json_decode retrieves my latest tweets, their date, etc.

<?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>';
?>

Problem is that $time outputs something like "03 February" even though there is a setlocale(LC_ALL, 'it_IT');. What's the error? How can I have dates output in italian? System: PHP 5.4.11 and nginx (on Ubuntu Server).

EDIT: I also ran dpkg-reconfigure locales:

Generating locales...
  en_US.UTF-8... up-to-date
  it_IT.UTF-8... up-to-date
Generation complete.
MultiformeIngegno
  • 6,959
  • 15
  • 60
  • 119
  • 1
    It *should* work: See http://php.net/manual/en/function.strftime.php. But the documentation goes on to say "Not all conversion specifiers may be supported by your C library, in which case they will not be supported by PHP's strftime()." – paulsm4 Feb 06 '13 at 19:29
  • Uhm.. so? What should I do? Should I try changing '%d %B' to something else? Anyway it's strange that they're not supported.. they're pretty basic! – MultiformeIngegno Feb 06 '13 at 19:31

1 Answers1

23

Silly as it may sound I solved changing the line to:

<?php setlocale(LC_ALL, 'it_IT.UTF-8'); ?> 
MultiformeIngegno
  • 6,959
  • 15
  • 60
  • 119
  • yeah, I have to wait 2 days. :) – MultiformeIngegno Feb 06 '13 at 23:57
  • 2
    After 2 hours of searching the web, i finally wanted to give up and then i clicked on a link which brought me here, and when i saw your answer @MultiformeIngegno it just clicked. I tried everything, but i forget to write the '-' between the UTF and 8. When i saw your answer i just knew that the "-" will make the trick. And id did. Thank you very much. – Mr. Sam Jul 07 '14 at 20:29
  • This is much better to use string replace all over the views. Thanks! – Kadaiser Sep 28 '18 at 06:49