Flarum 优化时间显示格式

找到“站点目录/vendor/flarum/core/js/dist/forum.js”,搜索“MMMM YYYY”,将format("MMMM YYYY")修改为format("ll"),搜索“D MMM”,将e.format("D MMM"):e.format("MMM 'YY")修改为e.format("ll"):e.format("ll")

找到“站点目录/vendor/flarum/statistics/js/dist/admin.js”,搜索“D MMM”,将:

moment.unix(h+i).utc().format("h A"):(d=moment.unix(h+i).utc().format("D MMM"),a.step>86400&&(d+=" - "+moment.unix(h+i+a.step-1).utc().format("D MMM")

修改为:

moment.unix(h+i).utc().format("LT"):(d=moment.unix(h+i).utc().format("l"),a.step>86400&&(d+=" - "+moment.unix(h+i+a.step-1).utc().format("l")

如果你的 Flarum 版本是 Btea14 及以上(包括正式版),那么就修改为:

dayjs. unix(h+i).utc().format("LT"):(d=moment.unix(h+i).utc().format("l"),a.step>86400&&(d+=" - "+moment.unix(h+i+a.step-1).utc().format("l")

然后记得清理浏览器缓存。

这样一来,Flarum 的时间显示格式就变成了“2022年6月17日”这样的格式,而不是原来的“日期在前月份在后”。

代码中的”ll”其实就是小写的字母“L”,如果想显示为其他的格式,那么可以改成这样:

代码显示的格式
L2022/06/17
l2022/6/17
LL2022/6/17
ll2022/6/17
LLL2022/6/17上午12点00分
lll2022/6/17 12:00
LLLL2022年6月17日星期五上午12点00分
llll2022年6月17日星期五 12:00
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇