简体   繁体   中英

Setlocale is correct but doesn't show Swedish signs

I have this strftime function to display dates:

    <?php 
        echo strftime('
        <div class="vecka">%a</div> 
        <div class="dag">%d</div> 
        <div class="man">%b</div>
        ', 
        strftime($article->eventDate));

                    ?>

I have set setlocale to: setlocale(LC_TIME,"swedish"); And the script does output the Swedish names for the month and day, but without the Swedish signs å, ä, ö which are substituted with a, a, o.

So måndag (monday in English) becomes mandag, lördag (saturday) becomes lordag, and so on...

It looks like's there's some problems with the utf8-encoding, so I tried to wrap it all in utf8_encode but with no result. The script does work on my local machine with xampp. The live server, where the script doesn't work, is debian.

I answer late, but it might help people who stumble upon this.

Add ".UTF-8" in the language parameter.

Example :

setlocale(LC_TIME, "fr_FR.UTF-8");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM