xRobot xRobot - 1 year ago 68
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 ?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download