doupiai5597 2013-11-24 23:57
浏览 52

PHP - 另一种语言的strftime输出是乱码[重复]

This question already has an answer here:

I have this code in PHP to translate dates to their locale

$date = time();
$locale_code = 'en_NZ';
$format_full_date = '%e %B %Y at %l:%M %P'; // 21 August 2013 at 3:26 am

// Set locale
setlocale(LC_ALL, $locale_code);

// Get date
$locale_date =  strftime(lang('format_full_date'), $date);

// Reset locale
setlocale(LC_ALL, 0);

This works fine in en_NZ. The output is something like 21 August 2013 at 8:26 pm

But when I change locale_code to fr_CA, I get outputted 21 ao�t 2013 at 8:26

There are two problems here

  • Why is the French August translation garbled?
  • Why is am/pm not showing?
</div>
  • 写回答

2条回答 默认 最新

  • dongxu1875 2013-11-24 23:58
    关注

    I'm guessing strftime outputs in a different encoding than your current Content-Encoding. Make sure they match or do a conversion. utf8_encode/utf8_decode might come in handy.

    August in French is août.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度