Is it possible to change $date content (to be exact, I want to translate it)
$date = date("l F d Y", $row['timestamp']);
Can I change each of the four values of this date (actually I would only need to change l and F) and make a new $date variable with new l and F values?
You can use PHP’s
$date = strtr($date, array(
'Monday' => 'lundi',
'Tuesday' => 'mardi',
'Wednesday' => 'mercredi',
'Thursday' => 'jeudi',
'Friday' => 'vendredi',
'Saturday' => 'samedi',
'Sunday' => 'dimanche'
Of course, the same applies to translating months.
$date = strftime('%A %B %d %Y', $row);
Although setlocale seems like an easier solution, it didn’t work for me, but strtr works perfectly
I probably should have mentioned there are stipulations with setlocale It relies entirely on the operating system and the locale you try to set needs to be installed on the system. There are also circumstances where the locale is named differently than you might expect. “french” could be “fr” or “French_France.1252″ or quite a few other possibilities. It’s often difficult getting it to work on a shared server.
You must be logged in to reply to this topic.