2013-02-06 13 views
6

Ho questo codice che attraverso json_decode recupera i miei ultimi tweet, la data, eccsetlocale (LC_ALL, 'it_IT'); set, ma le date ancora in inglese

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

Il problema è che il tempo $ emette qualcosa come "03 febbraio", anche se v'è una setlocale (LC_ALL, 'it_IT') ;. Qual è l'errore? Come posso avere date in uscita in italiano? Sistema: PHP 5.4.11 e nginx (su server Ubuntu).

EDIT: Ho anche eseguito dpkg-reconfigure locales:

Generating locales... 
    en_US.UTF-8... up-to-date 
    it_IT.UTF-8... up-to-date 
Generation complete. 
+1

E * deve * lavoro: Vedi http: //php.net/manual/en/function.strftime.php. Ma la documentazione continua dicendo "Non tutti gli specificatori di conversione possono essere supportati dalla libreria C, nel qual caso non saranno supportati da strftime() di PHP." – paulsm4

+0

Uhm .. quindi? Cosa dovrei fare? Dovrei provare a cambiare '% d% B' in qualcos'altro? Ad ogni modo è strano che non siano supportati .. sono piuttosto elementari! – MultiformeIngegno

risposta

15

sciocco come può sembrare ho risolto cambiando la linea a:

<?php setlocale(LC_ALL, 'it_IT.UTF-8'); ?> 
+0

Fresco. Sono contento che tu abbia funzionato! – paulsm4

+0

Non dimenticare di accettare la tua risposta – j0k

+0

sì, devo aspettare 2 giorni. :) – MultiformeIngegno