I’m working with a CMS spanish website, and I’m trying to replace the months to spanish.
This is how it looks like with the date function date(“F j, Y, g:i a”):
August 24, 2011, 1:47 pm
Now I want it to look like this:
Agosto 24, 2011, 1:47 pm
With str_replace function the string gets replaced, but the day and hour are missing.
Agosto
This is the code I’m using to define it:
date_default_timezone_set("America/Belize");
$p['time'] = date("F j, Y, g:i a");
$time = $p['time'];
$search = array('August', 'September', 'October', 'November', 'December');
$subject ='August';
$replace = array('Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
$time = str_replace($search, $replace, $subject);
$echo = $time;
Try using setlocale to specify the correct language before calling
date. E.g.P.S. In your original code, using that approach, you need to replace:
with
But I would recommend using
setlocaleso you don’t have to worry about doing this yourself. Also,is totally wrong; it should be: