Support » Plugins » Hacks » strtotime returns strange characters

  • Resolved luciendub

    (@luciendub)


    I want to show date of events created via custom post type and ACF in WordPress. I try to figure out why this:

    <?php setlocale(LC_TIME, 'fr_FR'); echo strftime('%d %h %Y', strtotime(get_field('date_de_levenement'))); ?>

    returns strange characters like this:

    04 ao�t 2014

    (Here the 04 ao�t 2014 should be 04 août 2014)

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You get that when either a font does not support a particular character, or there is a mismatch somewhere for which charset to use. I expect you see that character all the time in French with your font, so the problem is the latter. The charset is declared in several places, they should all match. Unless you have good reason not to, you should be using UTF-8.

    For good measure, add this line to your wp-config.php file just above the “stop editing” comment:
    @setlocale(LC_CTYPE, "fr_FR.utf8");

    Here’s other places you can check charset specifications, from memory, so likely incomplete:
    The DB_CHARSET constant in wp-config.php.
    Verify your pages in source view contain <meta charset="UTF-8">
    WP should be sending a header like this: 'Content-Type: text/plain; charset=utf-8'
    The WP settings page will have a charset field if it is not UTF-8, if you do not see it, WP is set for UTF-8.
    php.ini file if you have access to it.
    The fallback encoding set on your browser.
    .htaccess files can have charset declarations.

    Thread Starter luciendub

    (@luciendub)

    Yes, I was using the UTF-8.
    I finally solved the problem with utf8_encode

    So I get

    <?php setlocale(LC_TIME, 'fr_FR'); define("CHARSET", "utf-8"); echo utf8_encode (strftime('%d %h %Y', strtotime(get_field('date_de_levenement')))); ?>

    Thank you for your reply

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘strtotime returns strange characters’ is closed to new replies.