将openwrt的系统同步时间的显示修改为19700312 14:20的格式

对于像我这种英语直接不过关的,系统的日期显示为英文的月份还真不知道是啥。还是写成普通的格式看着顺眼。

下面就修改下系统返回的这个时间。用firebug查看返回的数据是一个json格式,日期的Key为timestring。

首先我们找到controller,位置在:/usr/lib/lua/luci/controller/admin/system.lua。

找到action_clock_status函数。在函数的结尾有以下两行:

    luci.http.prepare_content("application/json")
    luci.http.write_json({ timestring = os.date("%c") })

由此可见这个timestring是通过os.data()来返回,那么把这里改为我们想要的就ok了。

    luci.http.prepare_content("application/json")
    luci.http.write_json({ timestring = os.date("%Y-%m-%d %H:%M") })
原文地址:https://www.cnblogs.com/AUOONG/p/2453291.html