dsgdfh302506 2018-02-05 09:13
浏览 25
已采纳

有没有办法在没有前导空格的情况下使用`strftime`显示日期编号?

According to the documentation, strftime accepts a %e character in format parameter that returns the "day of the month, with a space preceding single digits".

So if I use it in order to display localized date I've got two different results, if I'm at the beginning of the month or the end of the month:

echo strftime('%A %e %B' . PHP_EOL);
// Displays: Monday  5 February

echo strftime('%A %e %B' . PHP_EOL, time() + 400000);
// Displays: Saturday 10 February

It's annoying and a bit weird. I don't know why this space is here (historical reasons?), I don't see any case where it's useful. But that's not the real question.

Is there a way to display a day number using strftime without leading space (and without leading zero)?

  • 写回答

2条回答 默认 最新

  • dongqiangse6623 2018-02-05 09:15
    关注

    The "brute-force" method is always an option:

    echo strftime('%A '), trim(strftime('%e')), strftime(' %B'), PHP_EOL;
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 socket通信实现多人聊天室疑惑
  • ¥15 DEV-C++编译缺失
  • ¥33 找熟练码农写段Pyhthon程序
  • ¥100 怎么让数据库字段自动更新
  • ¥15 antv g6 力导向图布局
  • ¥15 quartz框架,No record found for selection of Trigger with key
  • ¥15 锅炉建模+优化算法,遗传算法优化锅炉燃烧模型,ls-svm会搞,后面的智能算法不会
  • ¥20 MATLAB多目标优化问题求解
  • ¥15 windows2003服务器按你VPN教程设置后,本地win10如何连接?
  • ¥15 求一阶微分方程的幂级数