ianckc ianckc - 2 months ago 13x
PHP Question

php strftime French characters

I'm working on a site where the user can switch between English and French. To output the date of posts.

If the user chooses French I use:

setlocale(LC_ALL, 'fra_fra');

Then to output the date I use:

strftime('%d %B %Y', strtotime($post->post_date));

I have my charset at utf-8 with:

<meta charset="utf-8">

The problem I have is characters like รป and others with accents just display as the black diamonds with question marks in.

Is there a way to fix this?


This seems to be a problem / bug with the strftime function.

You can solve it using:

$date_string = utf8_encode(strftime('%d %B %Y', strtotime($post->post_date)));