【问题标题】:Formatting a date with Mako templates使用 Mako 模板格式化日期
【发布时间】:2012-12-15 13:55:37
【问题描述】:

在我的 mako 模板中,我有:

<p>${item.addDate}</p>

返回:

2012-12-27 19:50:00

但我想得到:

27/12/2012 19:50

mako 有什么漂亮的过滤器、格式功能吗?

【问题讨论】:

  • addDate 字符串还是日期时间对象?
  • @BurhanKhalid 为什么你的分析器被删除了?
  • 我删除了它,因为你的被接受了。
  • 我更喜欢你的回答,因为它有更多的细节。

标签: python pyramid mako


【解决方案1】:

根据googlestrftime 应该做的工作:

${post.date.strftime('%Y/%m/%d %H:%M')

另外,根据谷歌:

<%! from time import strftime as time %>
It is the ${"%d of %B" | time}

【讨论】:

    猜你喜欢
    • 2010-11-05
    • 2016-03-23
    • 2011-05-19
    • 2016-12-09
    • 1970-01-01
    • 1970-01-01
    • 2014-10-11
    • 2013-09-05
    • 1970-01-01
    相关资源
    最近更新 更多