4 Years
Discussion Span
Last Post by pritaeas


I need to convert string format "18 novembre 2012" (month is wrtite in italian) to php date.

I don't understand what you are trying to do?

You can't used date() function to do that.

You have to used strftime () function.

You can read more about it here:


You just want convert "18 novembre 2012" in Italian.

Try this:

//Questo รจ il modo di impostare l'ora locale in lingua italiana
setlocale(LC_TIME, 'it_IT');
//Questo eco la data: 18 novembre 2012 in italiano
echo strftime("%d %B %Y");

Edited by LastMitch: grammer


I think he needs to go the other way

18 novembre 2012 -> something else like 2012-11-18 or 18/11/2012

strtotime only works with English text. You could write your own function - pretty easy:

function toDate($date){
    list($day,$textmonth,$year) = explode(" ",$date);
    //if day in single digits:
    // $day = str_pad($day,2,'0',STR_PAD_LEFT);

    $m = array('gennaio'=>'01','febbraio'=>'02'...);
    $month = $m[$textmonth];
    //either this is enough:
    return $day . '/' . $month . '/' .$year;

    //or you can make a unixtimestamp with these and create any format you want

Locales are fine on UNix, Just try using them on Windows and you'll get an elephant-sized headache. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.