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
Had this issue but header(), utf8_encode() & setlocale() weren't working and we did not know the actual encoding. This is how we solved it (if it helps anyone) :
// $date_start is a DateTime instance
$month = strftime("%b", $date_start->getTimestamp());
// The default value for the 3rd argument is FALSE, this can cause issues
$encoding = mb_detect_encoding($month, 'auto', true);
// We can now correctly convert the string to UTF-8
$converted = mb_convert_encoding($month, 'UTF-8', $encoding);
Note: utf8_encode expects to encode from a ISO-8859-1 encoded string only.
Manual: