Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php strftime French characters

Tags:

php

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?

like image 651
ianckc Avatar asked Jan 24 '12 20:01

ianckc


1 Answers

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))); 
like image 59
jeroen Avatar answered Sep 25 '22 02:09

jeroen