-2

I have this line

<?php
echo date('H:i, d F Y',strtotime($i->date_start));
?>

Which outputs:

20:24, Saturday, 07 December 2013

How do I translate it to my local language?

PhearOfRayne
  • 4,860
  • 3
  • 30
  • 44
user3057167
  • 29
  • 1
  • 6
  • Please show an attempt to solve the problem yourself before your ask here. Here's a link to the PHP manual for the `date` function, it will contain everything you need: http://php.net/manual/en/function.date.php - and `setlocate` for your language: http://php.net/manual/en/function.setlocale.php – scrowler Dec 04 '13 at 19:01
  • I did not found how to translate it, and I do not now the location of the strtotime function to be able to translate it, I only have this line and I don`t know what to try! I suck – user3057167 Dec 04 '13 at 19:03
  • Look up `setlocate`, read the manual for it, and call it above your code. Don't bother with `strtotime` – scrowler Dec 04 '13 at 19:03
  • I also tried translating joomla names for month names with no effect – user3057167 Dec 04 '13 at 19:04
  • How does this http://stackoverflow.com/questions/6988536/strtotime-with-different-languages aswer my question !? – user3057167 Dec 04 '13 at 19:07

1 Answers1

2

You could use str_ireplace with an array of searches and an array of replacements.

$monthsDaysEn = array('January','February','March','Saturday','etc'); //populate with all months/days you want translated
$monthsDaysEs = array('enero','febero','marzo','Sabado','etc'); //populate in same order with their counterparts

$datestr = "20:24, Saturday, 07 March 2013";

$translated = str_ireplace($monthsEn,$monthsEs,$datestr);

echo $translated;
JustinM151
  • 754
  • 3
  • 11