view raw
xRobot xRobot - 9 months ago 35
PHP Question

Is there a fast way to convert date to spanish?

With this:

date( 'd F Y', strtotime( $row["datestart"] ) )

I get this:

08 July 2016

But I need to get this:

08 Julio 2016

Julio is July in spanish.

I have added this to the top of the php page:

setlocale(LC_TIME, 'es_ES');

but it doesn't work.

So what can I do ?


This worked for me:

setlocale(LC_TIME, 'es_ES', 'Spanish_Spain', 'Spanish'); 
$date = $date = str_replace("/","-","08/07/2016");
echo strftime('%d %B %Y',strtotime($date)); // 08 julio 2016

setlocale is the key ingredient here.