找到“站点目录/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”,如果想显示为其他的格式,那么可以改成这样:
代码 | 显示的格式 |
L | 2022/06/17 |
l | 2022/6/17 |
LL | 2022/6/17 |
ll | 2022/6/17 |
LLL | 2022/6/17上午12点00分 |
lll | 2022/6/17 12:00 |
LLLL | 2022年6月17日星期五上午12点00分 |
llll | 2022年6月17日星期五 12:00 |