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)));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With